UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = '7s7aRe7y+K+Rd6LoeaKxaAD4MAwvMDfpM8IwbEYaBFQ=' 
WHERE 
  key_id = '967e30f85ff582247b91d6d6a3d28258147c66fd5328e28f32e3ccb8ace38a10' 
  AND (
    token = '7s7aRe7y+K+Rd6LoeaKxaAD4MAwvMDfpM8IwbEYaBFQ=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00039