UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'i+iG0coUXdFhEgqbJClm35q3B6wmHE5C497nj8PUqyE=' 
WHERE 
  key_id = '77b2c5abeb111e0a0330a4731a442d823dbc388ebe70f1d55635cf995e10022f' 
  AND (
    token = 'i+iG0coUXdFhEgqbJClm35q3B6wmHE5C497nj8PUqyE=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00029