UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'KN7qPrP/P0Hb9KRFHcHBFV7xebvia4Ai7vd1Mc3wIhA=' 
WHERE 
  key_id = 'f824da8d4aa46fa3cd57e30340697f94e5785038239c4abb10a97bf17814ba07' 
  AND (
    token = 'KN7qPrP/P0Hb9KRFHcHBFV7xebvia4Ai7vd1Mc3wIhA=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00037