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

Query time 0.00037