##// END OF EJS Templates
vcs: Use a thread scoped cache invalidation context to cache repository objects....
Martin Bornhold -
r614:cbe55781 default
parent child Browse files
Show More
@@ -1977,7 +1977,7 b' class Repository(Base, BaseModel):'
1977 return self._get_instance()
1977 return self._get_instance()
1978
1978
1979 invalidator_context = CacheKey.repo_context_cache(
1979 invalidator_context = CacheKey.repo_context_cache(
1980 _get_repo, self.repo_name, None)
1980 _get_repo, self.repo_name, None, thread_scoped=True)
1981
1981
1982 with invalidator_context as context:
1982 with invalidator_context as context:
1983 context.invalidate()
1983 context.invalidate()
@@ -2848,7 +2848,8 b' class CacheKey(Base, BaseModel):'
2848 return None
2848 return None
2849
2849
2850 @classmethod
2850 @classmethod
2851 def repo_context_cache(cls, compute_func, repo_name, cache_type):
2851 def repo_context_cache(cls, compute_func, repo_name, cache_type,
2852 thread_scoped=False):
2852 """
2853 """
2853 @cache_region('long_term')
2854 @cache_region('long_term')
2854 def _heavy_calculation(cache_key):
2855 def _heavy_calculation(cache_key):
@@ -2864,7 +2865,8 b' class CacheKey(Base, BaseModel):'
2864 assert computed == 'result'
2865 assert computed == 'result'
2865 """
2866 """
2866 from rhodecode.lib import caches
2867 from rhodecode.lib import caches
2867 return caches.InvalidationContext(compute_func, repo_name, cache_type)
2868 return caches.InvalidationContext(
2869 compute_func, repo_name, cache_type, thread_scoped=thread_scoped)
2868
2870
2869
2871
2870 class ChangesetComment(Base, BaseModel):
2872 class ChangesetComment(Base, BaseModel):
General Comments 0
You need to be logged in to leave comments. Login now