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

Query time 0.00037