UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'Sw3kLYEujOjJw9Q3f52sdNZIMvbXNRczt10fz43epHI=' 
WHERE 
  key_id = 'a6981257d59305870aaf7603a37cbd3f4f21941ffc710929d71009b7dca72dad' 
  AND (
    token = 'Sw3kLYEujOjJw9Q3f52sdNZIMvbXNRczt10fz43epHI=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00040