UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'BYaY8w5KpumklPkYOfPEFqy4IK9INnQTjmKXxDmO4As=' 
WHERE 
  key_id = '9f561a204269917188cda08001c44efd56f26cb45989a881c7f953ca77e37698' 
  AND (
    token = 'BYaY8w5KpumklPkYOfPEFqy4IK9INnQTjmKXxDmO4As=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00050