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

Query time 0.00016