Changeset - f18801f827da
[Not reviewed]
beta
0 1 0
Marcin Kuzminski - 13 years ago 2013-04-05 13:27:28
marcin@python-works.com
repr of cache inv object show also now cache_active + some better logging
1 file changed with 5 insertions and 3 deletions:
0 comments (0 inline, 0 general)
rhodecode/model/db.py
Show inline comments
 
@@ -1164,13 +1164,12 @@ class Repository(Base, BaseModel):
 

	
 
    def scm_instance_cached(self, cache_map=None):
 
        @cache_region('long_term')
 
        def _c(repo_name):
 
            return self.__get_instance()
 
        rn = self.repo_name
 
        log.debug('Getting cached instance of repo')
 

	
 
        if cache_map:
 
            # get using prefilled cache_map
 
            invalidate_repo = cache_map[self.repo_name]
 
            if invalidate_repo:
 
                invalidate_repo = (None if invalidate_repo.cache_active
 
@@ -1178,14 +1177,17 @@ class Repository(Base, BaseModel):
 
        else:
 
            # get from invalidate
 
            invalidate_repo = self.invalidate
 

	
 
        if invalidate_repo is not None:
 
            region_invalidate(_c, None, rn)
 
            log.debug('Cache for %s invalidated, getting new object' % (rn))
 
            # update our cache
 
            CacheInvalidation.set_valid(invalidate_repo.cache_key)
 
        else:
 
            log.debug('Getting obj for %s from cache' % (rn))
 
        return _c(rn)
 

	
 
    def __get_instance(self):
 
        repo_full_path = self.repo_full_path
 
        try:
 
            alias = get_scm(repo_full_path)[0]
 
@@ -1645,14 +1647,14 @@ class CacheInvalidation(Base, BaseModel)
 
    def __init__(self, cache_key, repo_name=''):
 
        self.cache_key = cache_key
 
        self.cache_args = repo_name
 
        self.cache_active = False
 

	
 
    def __unicode__(self):
 
        return u"<%s('%s:%s')>" % (self.__class__.__name__,
 
                                  self.cache_id, self.cache_key)
 
        return u"<%s('%s:%s[%s]')>" % (self.__class__.__name__,
 
                            self.cache_id, self.cache_key, self.cache_active)
 

	
 
    def get_prefix(self):
 
        """
 
        Guess prefix that might have been used in _get_cache_key to generate self.cache_key .
 
        Only used for informational purposes in repo_edit.html .
 
        """
0 comments (0 inline, 0 general)