##// END OF EJS Templates
caches: use context based cache for repository....
marcink -
r2948:c4685cb8 default
parent child Browse files
Show More
@@ -2336,16 +2336,17 b' class Repository(Base, BaseModel):'
2336 region = rc_cache.get_or_create_region('cache_repo_longterm', cache_namespace_uid)
2336 region = rc_cache.get_or_create_region('cache_repo_longterm', cache_namespace_uid)
2337
2337
2338 @region.conditional_cache_on_arguments(namespace=cache_namespace_uid)
2338 @region.conditional_cache_on_arguments(namespace=cache_namespace_uid)
2339 def get_instance_cached(repo_id):
2339 def get_instance_cached(repo_id, context_id):
2340 return self._get_instance()
2340 return self._get_instance()
2341
2341
2342 # we must use thread scoped cache here,
2342 # we must use thread scoped cache here,
2343 # because each thread of gevent needs it's own connection and cache
2343 # because each thread of gevent needs it's own not shared connection and cache
2344 # we also alter `args` so the cache key is individual for every green thread.
2344 inv_context_manager = rc_cache.InvalidationContext(
2345 inv_context_manager = rc_cache.InvalidationContext(
2345 uid=cache_namespace_uid, invalidation_namespace=invalidation_namespace,
2346 uid=cache_namespace_uid, invalidation_namespace=invalidation_namespace,
2346 thread_scoped=True)
2347 thread_scoped=True)
2347 with inv_context_manager as invalidation_context:
2348 with inv_context_manager as invalidation_context:
2348 args = (self.repo_id,)
2349 args = (self.repo_id, inv_context_manager.cache_key)
2349 # re-compute and store cache if we get invalidate signal
2350 # re-compute and store cache if we get invalidate signal
2350 if invalidation_context.should_invalidate():
2351 if invalidation_context.should_invalidate():
2351 instance = get_instance_cached.refresh(*args)
2352 instance = get_instance_cached.refresh(*args)
General Comments 0
You need to be logged in to leave comments. Login now