Mercurial > kallithea
comparison rhodecode/model/scm.py @ 726:04c4e5f94cee beta
cache list speed improvement
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Fri, 19 Nov 2010 03:00:05 +0100 |
parents | a9bc513a1fe3 |
children | 49eb69d78988 |
comparison
equal
deleted
inserted
replaced
725:7a6c971a5f0e | 726:04c4e5f94cee |
---|---|
104 """ | 104 """ |
105 if not all_repos: | 105 if not all_repos: |
106 all_repos = self.sa.query(Repository)\ | 106 all_repos = self.sa.query(Repository)\ |
107 .order_by(Repository.repo_name).all() | 107 .order_by(Repository.repo_name).all() |
108 | 108 |
109 invalidation_list = [str(x.cache_key) for x in \ | |
110 self.sa.query(CacheInvalidation.cache_key)\ | |
111 .filter(CacheInvalidation.cache_active == False)\ | |
112 .all()] | |
113 | |
109 for r in all_repos: | 114 for r in all_repos: |
110 | 115 |
111 repo = self.get(r.repo_name) | 116 repo = self.get(r.repo_name, invalidation_list) |
112 | 117 |
113 if repo is not None: | 118 if repo is not None: |
114 last_change = repo.last_change | 119 last_change = repo.last_change |
115 tip = h.get_changeset_safe(repo, 'tip') | 120 tip = h.get_changeset_safe(repo, 'tip') |
116 | 121 |
132 yield tmp_d | 137 yield tmp_d |
133 | 138 |
134 def get_repo(self, repo_name): | 139 def get_repo(self, repo_name): |
135 return self.get(repo_name) | 140 return self.get(repo_name) |
136 | 141 |
137 def get(self, repo_name): | 142 def get(self, repo_name, invalidation_list=None): |
138 """ | 143 """ |
139 Get's repository from given name, creates BackendInstance and | 144 Get's repository from given name, creates BackendInstance and |
140 propagates it's data from database with all additional information | 145 propagates it's data from database with all additional information |
141 :param repo_name: | 146 :param repo_name: |
142 """ | 147 """ |
170 .scalar() | 175 .scalar() |
171 make_transient(dbrepo) | 176 make_transient(dbrepo) |
172 repo.dbrepo = dbrepo | 177 repo.dbrepo = dbrepo |
173 return repo | 178 return repo |
174 | 179 |
175 invalidate = self._should_invalidate(repo_name) | 180 pre_invalidate = True |
176 if invalidate: | 181 if invalidation_list: |
177 log.info('invalidating cache for repository %s', repo_name) | 182 pre_invalidate = repo_name in invalidation_list |
178 region_invalidate(_get_repo, None, repo_name) | 183 |
179 self._mark_invalidated(invalidate) | 184 if pre_invalidate: |
185 invalidate = self._should_invalidate(repo_name) | |
186 | |
187 if invalidate: | |
188 log.info('invalidating cache for repository %s', repo_name) | |
189 region_invalidate(_get_repo, None, repo_name) | |
190 self._mark_invalidated(invalidate) | |
180 | 191 |
181 return _get_repo(repo_name) | 192 return _get_repo(repo_name) |
182 | 193 |
183 | 194 |
184 | 195 |