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

Query time 0.00026