# HG changeset patch # User Mads Kiilerich # Date 2016-03-08 15:50:54 # Node ID b45fb7a3d03badc39b9ef9ed9451ab33768d8f09 # Parent b5bef0b3920976bd0423b44de2d053c5160aab2a db: minor changes for repo caching diff --git a/kallithea/lib/utils.py b/kallithea/lib/utils.py --- a/kallithea/lib/utils.py +++ b/kallithea/lib/utils.py @@ -857,7 +857,7 @@ def conditional_cache(region, prefix, co return data # denpending from condition the compute is wrapped in cache or not - compute = conditional_cache('short_term', 'cache_desc', codnition=True, func=func) + compute = conditional_cache('short_term', 'cache_desc', condition=True, func=func) return compute(arg) :param region: name of cache region diff --git a/kallithea/model/db.py b/kallithea/model/db.py --- a/kallithea/model/db.py +++ b/kallithea/model/db.py @@ -1450,7 +1450,8 @@ class Repository(Base, BaseModel): def scm_instance_cached(self, valid_cache_keys=None): @cache_region('long_term') - def _c(repo_name): + def _c(repo_name): # repo_name is just for the cache key + log.debug('Creating new %s scm_instance and populating cache', repo_name) return self.__get_instance() rn = self.repo_name @@ -1459,7 +1460,7 @@ class Repository(Base, BaseModel): log.debug('Cache for %s invalidated, getting new object', rn) region_invalidate(_c, None, rn) else: - log.debug('Getting scm_instance of %s from cache', rn) + log.debug('Trying to get scm_instance of %s from cache', rn) return _c(rn) def __get_instance(self): @@ -2133,7 +2134,7 @@ class CacheInvalidation(Base, BaseModel) inv_obj = cls.query().filter(cls.cache_key == cache_key).scalar() if inv_obj is None: - inv_obj = CacheInvalidation(cache_key, repo_name) + inv_obj = cls(cache_key, repo_name) elif inv_obj.cache_active: return True inv_obj.cache_active = True