UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'smjwNvII1Jsb2mdGdpQ53NhR4dTFSKoDY0BUxwYAeNk=' 
WHERE 
  key_id = 'e9b845636cd9829366e18c650a87cb6806018446fa627f150856230089e88d6d' 
  AND (
    token = 'smjwNvII1Jsb2mdGdpQ53NhR4dTFSKoDY0BUxwYAeNk=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00034