UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'rIsBQFTrOeVeK8Tey0TtZiKaqWPSuFFVkehLqhgBngc=' 
WHERE 
  key_id = '3cd74a3e18801607209817ae28b954a9d09ed82722119712e983ac3a54c9c8b7' 
  AND (
    token = 'rIsBQFTrOeVeK8Tey0TtZiKaqWPSuFFVkehLqhgBngc=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00037