UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'tQyK6yz40fz6J4CO9K9jF8wMvG1fZLqVt8NVo1zReBQ=' 
WHERE 
  key_id = '1a653c59e355cbd781fa3ce41b69403fc9d50d85ab23af3e52d050b58622258e' 
  AND (
    token = 'tQyK6yz40fz6J4CO9K9jF8wMvG1fZLqVt8NVo1zReBQ=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00038