From 6ed37d241025bf577383a92f186f0b21c09ad6c1 Mon Sep 17 00:00:00 2001 From: Brant Knudson Date: Thu, 22 Sep 2016 17:29:40 -0500 Subject: [PATCH] Request cache should not update context The request context is kind of important. It has info like the request cache and auth info for the request. The request cache should not be modifying the request context. The code here makes it look like the request cache needs to update the thread's request context but it actually never does change it since even if it creates a new RequestContext the new instance becomes the new thread request context. Change-Id: Ib824648fe7cb6b3614e03f7d2570fbbfc0c3a88d --- keystone/common/cache/_context_cache.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/keystone/common/cache/_context_cache.py b/keystone/common/cache/_context_cache.py index 8a848f51e..8c526065c 100644 --- a/keystone/common/cache/_context_cache.py +++ b/keystone/common/cache/_context_cache.py @@ -39,14 +39,12 @@ class _ResponseCacheProxy(proxy.ProxyBackend): def _get_request_key(self, key): return self.__key_pfx % key - def _set_local_cache(self, key, value, ctx=None): + def _set_local_cache(self, key, value): # Set a serialized version of the returned value in local cache for # subsequent calls to the memoized method. - if not ctx: - ctx = self._get_request_context() + ctx = self._get_request_context() serialize = {'payload': value.payload, 'metadata': value.metadata} setattr(ctx, self._get_request_key(key), msgpackutils.dumps(serialize)) - ctx.update_store() def _get_local_cache(self, key): # Return the version from our local request cache if it exists. @@ -65,7 +63,6 @@ class _ResponseCacheProxy(proxy.ProxyBackend): ctx = self._get_request_context() try: delattr(ctx, self._get_request_key(key)) - ctx.update_store() except AttributeError: # nosec # NOTE(morganfainberg): We will simply pass here, this value has # not been cached locally in the request. @@ -99,9 +96,8 @@ class _ResponseCacheProxy(proxy.ProxyBackend): return [values[k] for k in keys] def set_multi(self, mapping): - ctx = self._get_request_context() for k, v in mapping.items(): - self._set_local_cache(k, v, ctx) + self._set_local_cache(k, v) self.proxied.set_multi(mapping) def delete_multi(self, keys):