diff --git a/keystone/server/backends.py b/keystone/server/backends.py index 34d8a593b7..e6c140a639 100644 --- a/keystone/server/backends.py +++ b/keystone/server/backends.py @@ -41,6 +41,7 @@ def load_backends(): cache.configure_cache(region=revoke.REVOKE_REGION) cache.apply_invalidation_patch(region=revoke.REVOKE_REGION, region_name=revoke.REVOKE_REGION.name) + cache.configure_cache(region=token.provider.TOKENS_REGION) # Ensure that the identity driver is created before the assignment manager # and that the assignment driver is created before the resource manager. diff --git a/keystone/token/provider.py b/keystone/token/provider.py index 9f29cd6db5..8c9fdcf295 100644 --- a/keystone/token/provider.py +++ b/keystone/token/provider.py @@ -20,6 +20,7 @@ import datetime import sys import uuid +from oslo_cache import core as oslo_cache from oslo_log import log from oslo_utils import timeutils import six @@ -39,7 +40,11 @@ from keystone.token import utils CONF = keystone.conf.CONF LOG = log.getLogger(__name__) -MEMOIZE = cache.get_memoization_decorator(group='token') + +TOKENS_REGION = oslo_cache.create_region() +MEMOIZE_TOKENS = cache.get_memoization_decorator( + group='token', + region=TOKENS_REGION) # NOTE(morganfainberg): This is for compatibility in case someone was relying # on the old location of the UnsupportedTokenVersionException for their code. @@ -287,11 +292,11 @@ class Manager(manager.Manager): LOG.debug('Unable to validate token: %s', e) raise exception.TokenNotFound(token_id=token_id) - @MEMOIZE + @MEMOIZE_TOKENS def validate_non_persistent_token(self, token_id): return self.driver.validate_non_persistent_token(token_id) - @MEMOIZE + @MEMOIZE_TOKENS def _validate_token(self, token_id): if not token_id: raise exception.TokenNotFound(_('No token in the request')) @@ -312,11 +317,11 @@ class Manager(manager.Manager): return self.driver.validate_v2_token(token_ref) raise exception.UnsupportedTokenVersionException() - @MEMOIZE + @MEMOIZE_TOKENS def _validate_v2_token(self, token_id): return self.driver.validate_v2_token(token_id) - @MEMOIZE + @MEMOIZE_TOKENS def _validate_v3_token(self, token_id): return self.driver.validate_v3_token(token_id)