##// END OF EJS Templates
cache list speed improvement
marcink -
r726:04c4e5f9 beta
parent child Browse files
Show More
@@ -106,9 +106,14 b' class ScmModel(object):'
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
@@ -134,7 +139,7 b' class ScmModel(object):'
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
@@ -172,7 +177,13 b' class ScmModel(object):'
172 repo.dbrepo = dbrepo
177 repo.dbrepo = dbrepo
173 return repo
178 return repo
174
179
180 pre_invalidate = True
181 if invalidation_list:
182 pre_invalidate = repo_name in invalidation_list
183
184 if pre_invalidate:
175 invalidate = self._should_invalidate(repo_name)
185 invalidate = self._should_invalidate(repo_name)
186
176 if invalidate:
187 if invalidate:
177 log.info('invalidating cache for repository %s', repo_name)
188 log.info('invalidating cache for repository %s', repo_name)
178 region_invalidate(_get_repo, None, repo_name)
189 region_invalidate(_get_repo, None, repo_name)
General Comments 0
You need to be logged in to leave comments. Login now