UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'c4UTEanA+kGBf2SeYk3LPfVR2Wmdu0hYNkRbddjOwfY=' 
WHERE 
  key_id = 'ce1066b18aebce14b2c2acbc6c4b109810a61380499bbd1a15a032591b9aee80' 
  AND (
    token = 'c4UTEanA+kGBf2SeYk3LPfVR2Wmdu0hYNkRbddjOwfY=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00030