UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'pi+JckX8IP803oFTFq9MTH87wRKAlTychTKIQ1ingZI=' 
WHERE 
  key_id = 'd4fc4e11a021a467a6aba1bf1ece87a08d22c238c995aa5bb01bed65b01080b1' 
  AND (
    token = 'pi+JckX8IP803oFTFq9MTH87wRKAlTychTKIQ1ingZI=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00032