diff --git a/jupyterhub/services/auth.py b/jupyterhub/services/auth.py index ef80799f..4ce9ed84 100644 --- a/jupyterhub/services/auth.py +++ b/jupyterhub/services/auth.py @@ -277,11 +277,10 @@ class HubAuth(SingletonConfigurable): if cache_key is None: raise ValueError("cache_key is required when using cache") # check for a cached reply, so we don't check with the Hub if we don't have to - cached = self.cache.get(cache_key) - if cached is not None: - return cached - else: - app_log.debug("Cache miss: %s" % cache_key) + try: + return self.cache[cache_key] + except KeyError: + app_log.debug("HubAuth cache miss: %s", cache_key) data = self._api_request('GET', url, allow_404=True) if data is None: