UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'lc7TDgrcBSnR+JjnZ2QQ2Cid61zJwX/bLkxa3rlC9jg=' 
WHERE 
  key_id = '1df6004ceebd8222fae3fed3e21164e1e8374f9d12e9c4a64903465e4350531f' 
  AND (
    token = 'lc7TDgrcBSnR+JjnZ2QQ2Cid61zJwX/bLkxa3rlC9jg=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00036