UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'n5V0USA05jnwntRWMCVFCMzQ8qrcIfbeLmhiSNzeTCk=' 
WHERE 
  key_id = '52c552fa39566adaa7007f7d241b76e8f989c5a250d24e770314da6efdf65147' 
  AND (
    token = 'n5V0USA05jnwntRWMCVFCMzQ8qrcIfbeLmhiSNzeTCk=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00047