UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'fx/r37SmosTvV3laOabBiU+hmrlDqN40AhVrG/3Agrs=' 
WHERE 
  key_id = 'a8782e2545d8a2434ed239df34fe430624698e579fd24992ade229ecca0d4495' 
  AND (
    token = 'fx/r37SmosTvV3laOabBiU+hmrlDqN40AhVrG/3Agrs=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00034