changeset 5750:b45fb7a3d03b

db: minor changes for repo caching
author Mads Kiilerich <madski@unity3d.com>
date Tue, 08 Mar 2016 15:50:54 +0100
parents b5bef0b39209
children 1883a4e4c390
files kallithea/lib/utils.py kallithea/model/db.py
diffstat 2 files changed, 5 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/kallithea/lib/utils.py	Wed Mar 02 16:21:11 2016 +0100
+++ b/kallithea/lib/utils.py	Tue Mar 08 15:50:54 2016 +0100
@@ -857,7 +857,7 @@
             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
--- a/kallithea/model/db.py	Wed Mar 02 16:21:11 2016 +0100
+++ b/kallithea/model/db.py	Tue Mar 08 15:50:54 2016 +0100
@@ -1450,7 +1450,8 @@
 
     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 @@
             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 @@
 
         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