Mercurial > kallithea
comparison rhodecode/model/db.py @ 3686:f18801f827da beta
repr of cache inv object show also now cache_active + some better logging
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Fri, 05 Apr 2013 13:27:28 +0200 |
parents | 02e1e270bf93 |
children | 8849c07d8c62 |
comparison
equal
deleted
inserted
replaced
3685:02e1e270bf93 | 3686:f18801f827da |
---|---|
1165 def scm_instance_cached(self, cache_map=None): | 1165 def scm_instance_cached(self, cache_map=None): |
1166 @cache_region('long_term') | 1166 @cache_region('long_term') |
1167 def _c(repo_name): | 1167 def _c(repo_name): |
1168 return self.__get_instance() | 1168 return self.__get_instance() |
1169 rn = self.repo_name | 1169 rn = self.repo_name |
1170 log.debug('Getting cached instance of repo') | |
1171 | 1170 |
1172 if cache_map: | 1171 if cache_map: |
1173 # get using prefilled cache_map | 1172 # get using prefilled cache_map |
1174 invalidate_repo = cache_map[self.repo_name] | 1173 invalidate_repo = cache_map[self.repo_name] |
1175 if invalidate_repo: | 1174 if invalidate_repo: |
1179 # get from invalidate | 1178 # get from invalidate |
1180 invalidate_repo = self.invalidate | 1179 invalidate_repo = self.invalidate |
1181 | 1180 |
1182 if invalidate_repo is not None: | 1181 if invalidate_repo is not None: |
1183 region_invalidate(_c, None, rn) | 1182 region_invalidate(_c, None, rn) |
1183 log.debug('Cache for %s invalidated, getting new object' % (rn)) | |
1184 # update our cache | 1184 # update our cache |
1185 CacheInvalidation.set_valid(invalidate_repo.cache_key) | 1185 CacheInvalidation.set_valid(invalidate_repo.cache_key) |
1186 else: | |
1187 log.debug('Getting obj for %s from cache' % (rn)) | |
1186 return _c(rn) | 1188 return _c(rn) |
1187 | 1189 |
1188 def __get_instance(self): | 1190 def __get_instance(self): |
1189 repo_full_path = self.repo_full_path | 1191 repo_full_path = self.repo_full_path |
1190 try: | 1192 try: |
1646 self.cache_key = cache_key | 1648 self.cache_key = cache_key |
1647 self.cache_args = repo_name | 1649 self.cache_args = repo_name |
1648 self.cache_active = False | 1650 self.cache_active = False |
1649 | 1651 |
1650 def __unicode__(self): | 1652 def __unicode__(self): |
1651 return u"<%s('%s:%s')>" % (self.__class__.__name__, | 1653 return u"<%s('%s:%s[%s]')>" % (self.__class__.__name__, |
1652 self.cache_id, self.cache_key) | 1654 self.cache_id, self.cache_key, self.cache_active) |
1653 | 1655 |
1654 def get_prefix(self): | 1656 def get_prefix(self): |
1655 """ | 1657 """ |
1656 Guess prefix that might have been used in _get_cache_key to generate self.cache_key . | 1658 Guess prefix that might have been used in _get_cache_key to generate self.cache_key . |
1657 Only used for informational purposes in repo_edit.html . | 1659 Only used for informational purposes in repo_edit.html . |