UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'HvlAt+8uVHfvxL8M7TO3mV3gmc/5FiViZv2TbDjin4s=' 
WHERE 
  key_id = '4db77e3e354ba328e971e9f564518c350ce9a76250736097e80b07276262773e' 
  AND (
    token = 'HvlAt+8uVHfvxL8M7TO3mV3gmc/5FiViZv2TbDjin4s=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00043