UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'IP76AkxE3jqAl9BoBxxp0hDKDoviDhQOwKSEKwT/z5Y=' 
WHERE 
  key_id = '6c2fff95b3014d0581214b80a211313aded5d9793a647b3e4ef9467952888982' 
  AND (
    token = 'IP76AkxE3jqAl9BoBxxp0hDKDoviDhQOwKSEKwT/z5Y=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00021