UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'toyr+iAZh1mMNCwzEQ6NflJhSKQ76VEjehsZh+IyAXc=' 
WHERE 
  key_id = 'e09965b8614f78e4d9fb937e6a794ec50b02bcce08deb4f96c39941fe1c40aa8' 
  AND (
    token = 'toyr+iAZh1mMNCwzEQ6NflJhSKQ76VEjehsZh+IyAXc=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00023