UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'NB2B8VjJxnUTc5Yt0dRvl8UjFhdwfetPdghHl+Twrg0=' 
WHERE 
  key_id = '8215e057ecf3110c46134f0a957caa51891ad95c497300cd66bf5242f71b2735' 
  AND (
    token = 'NB2B8VjJxnUTc5Yt0dRvl8UjFhdwfetPdghHl+Twrg0=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00025