Show More
@@ -448,8 +448,10 b' def repo2db_mapper(initial_repo_list, re' | |||||
448 | # during starting install all cache keys for all repositories in the |
|
448 | # during starting install all cache keys for all repositories in the | |
449 | # system, this will register all repos and multiple instances |
|
449 | # system, this will register all repos and multiple instances | |
450 | key, _prefix, _org_key = CacheInvalidation._get_key(name) |
|
450 | key, _prefix, _org_key = CacheInvalidation._get_key(name) | |
451 | log.debug("Creating a cache key for %s instance_id:`%s`" % (name, _prefix)) |
|
451 | CacheInvalidation.invalidate(name) | |
452 | CacheInvalidation._get_or_create_key(key, _prefix, _org_key, commit=False) |
|
452 | log.debug("Creating a cache key for %s instance_id=>`%s`" | |
|
453 | % (name, _prefix or '-')) | |||
|
454 | ||||
453 | sa.commit() |
|
455 | sa.commit() | |
454 | removed = [] |
|
456 | removed = [] | |
455 | if remove_obsolete: |
|
457 | if remove_obsolete: |
@@ -937,7 +937,7 b' class Repository(Base, BaseModel):' | |||||
937 | """ |
|
937 | """ | |
938 | set a cache for invalidation for this instance |
|
938 | set a cache for invalidation for this instance | |
939 | """ |
|
939 | """ | |
940 | CacheInvalidation.set_invalidate(self.repo_name) |
|
940 | CacheInvalidation.set_invalidate(repo_name=self.repo_name) | |
941 |
|
941 | |||
942 | @LazyProperty |
|
942 | @LazyProperty | |
943 | def scm_instance(self): |
|
943 | def scm_instance(self): | |
@@ -1438,25 +1438,27 b' class CacheInvalidation(Base, BaseModel)' | |||||
1438 | """ |
|
1438 | """ | |
1439 | import rhodecode |
|
1439 | import rhodecode | |
1440 | prefix = '' |
|
1440 | prefix = '' | |
|
1441 | org_key = key | |||
1441 | iid = rhodecode.CONFIG.get('instance_id') |
|
1442 | iid = rhodecode.CONFIG.get('instance_id') | |
1442 | if iid: |
|
1443 | if iid: | |
1443 | prefix = iid |
|
1444 | prefix = iid | |
1444 | #remove specific suffixes like _README or _RSS |
|
1445 | ||
1445 | key = remove_suffix(key, '_README') |
|
1446 | return "%s%s" % (prefix, key), prefix, org_key | |
1446 | key = remove_suffix(key, '_RSS') |
|
|||
1447 | key = remove_suffix(key, '_ATOM') |
|
|||
1448 | return "%s%s" % (prefix, key), prefix, key |
|
|||
1449 |
|
1447 | |||
1450 | @classmethod |
|
1448 | @classmethod | |
1451 | def get_by_key(cls, key): |
|
1449 | def get_by_key(cls, key): | |
1452 | return cls.query().filter(cls.cache_key == key).scalar() |
|
1450 | return cls.query().filter(cls.cache_key == key).scalar() | |
1453 |
|
1451 | |||
1454 | @classmethod |
|
1452 | @classmethod | |
1455 | def _get_or_create_key(cls, key, prefix, org_key, commit=True): |
|
1453 | def get_by_repo_name(cls, repo_name): | |
|
1454 | return cls.query().filter(cls.cache_args == repo_name).all() | |||
|
1455 | ||||
|
1456 | @classmethod | |||
|
1457 | def _get_or_create_key(cls, key, repo_name, commit=True): | |||
1456 | inv_obj = Session().query(cls).filter(cls.cache_key == key).scalar() |
|
1458 | inv_obj = Session().query(cls).filter(cls.cache_key == key).scalar() | |
1457 | if not inv_obj: |
|
1459 | if not inv_obj: | |
1458 | try: |
|
1460 | try: | |
1459 |
inv_obj = CacheInvalidation(key, |
|
1461 | inv_obj = CacheInvalidation(key, repo_name) | |
1460 | Session().add(inv_obj) |
|
1462 | Session().add(inv_obj) | |
1461 | if commit: |
|
1463 | if commit: | |
1462 | Session().commit() |
|
1464 | Session().commit() | |
@@ -1474,30 +1476,38 b' class CacheInvalidation(Base, BaseModel)' | |||||
1474 |
|
1476 | |||
1475 | :param key: |
|
1477 | :param key: | |
1476 | """ |
|
1478 | """ | |
|
1479 | repo_name = key | |||
|
1480 | repo_name = remove_suffix(repo_name, '_README') | |||
|
1481 | repo_name = remove_suffix(repo_name, '_RSS') | |||
|
1482 | repo_name = remove_suffix(repo_name, '_ATOM') | |||
1477 |
|
1483 | |||
|
1484 | # adds instance prefix | |||
1478 | key, _prefix, _org_key = cls._get_key(key) |
|
1485 | key, _prefix, _org_key = cls._get_key(key) | |
1479 |
inv = cls._get_or_create_key(key, |
|
1486 | inv = cls._get_or_create_key(key, repo_name) | |
1480 |
|
1487 | |||
1481 | if inv and inv.cache_active is False: |
|
1488 | if inv and inv.cache_active is False: | |
1482 | return inv |
|
1489 | return inv | |
1483 |
|
1490 | |||
1484 | @classmethod |
|
1491 | @classmethod | |
1485 | def set_invalidate(cls, key): |
|
1492 | def set_invalidate(cls, key=None, repo_name=None): | |
1486 | """ |
|
1493 | """ | |
1487 | Mark this Cache key for invalidation |
|
1494 | Mark this Cache key for invalidation, either by key or whole | |
|
1495 | cache sets based on repo_name | |||
1488 |
|
1496 | |||
1489 | :param key: |
|
1497 | :param key: | |
1490 | """ |
|
1498 | """ | |
1491 |
|
1499 | if key: | ||
1492 | key, _prefix, _org_key = cls._get_key(key) |
|
1500 | key, _prefix, _org_key = cls._get_key(key) | |
1493 |
inv_objs = Session().query(cls).filter(cls.cache_ |
|
1501 | inv_objs = Session().query(cls).filter(cls.cache_key == key).all() | |
1494 | log.debug('marking %s key[s] %s for invalidation' % (len(inv_objs), |
|
1502 | elif repo_name: | |
1495 | _org_key)) |
|
1503 | inv_objs = Session().query(cls).filter(cls.cache_args == repo_name).all() | |
|
1504 | ||||
|
1505 | log.debug('marking %s key[s] for invalidation based on key=%s,repo_name=%s' | |||
|
1506 | % (len(inv_objs), key, repo_name)) | |||
1496 | try: |
|
1507 | try: | |
1497 | for inv_obj in inv_objs: |
|
1508 | for inv_obj in inv_objs: | |
1498 |
|
|
1509 | print inv_obj | |
1499 |
|
|
1510 | inv_obj.cache_active = False | |
1500 |
|
||||
1501 | Session().add(inv_obj) |
|
1511 | Session().add(inv_obj) | |
1502 | Session().commit() |
|
1512 | Session().commit() | |
1503 | except Exception: |
|
1513 | except Exception: |
@@ -291,7 +291,7 b' class ScmModel(BaseModel):' | |||||
291 |
|
291 | |||
292 | :param repo_name: this repo that should invalidation take place |
|
292 | :param repo_name: this repo that should invalidation take place | |
293 | """ |
|
293 | """ | |
294 | CacheInvalidation.set_invalidate(repo_name) |
|
294 | CacheInvalidation.set_invalidate(repo_name=repo_name) | |
295 |
|
295 | |||
296 | def toggle_following_repo(self, follow_repo_id, user_id): |
|
296 | def toggle_following_repo(self, follow_repo_id, user_id): | |
297 |
|
297 |
@@ -1627,6 +1627,7 b' div.form div.fields div.field div.button' | |||||
1627 | background: #eee; |
|
1627 | background: #eee; | |
1628 | border-bottom: 1px solid #ddd; |
|
1628 | border-bottom: 1px solid #ddd; | |
1629 | padding: 5px 0px 5px 5px; |
|
1629 | padding: 5px 0px 5px 5px; | |
|
1630 | text-align: left; | |||
1630 | } |
|
1631 | } | |
1631 |
|
1632 | |||
1632 | #content div.box table th.left { |
|
1633 | #content div.box table th.left { |
@@ -196,11 +196,20 b'' | |||||
196 | </div> |
|
196 | </div> | |
197 | <div class="field" style="border:none;"> |
|
197 | <div class="field" style="border:none;"> | |
198 | ${_('List of cached values')} |
|
198 | ${_('List of cached values')} | |
199 |
< |
|
199 | <table> | |
|
200 | <tr> | |||
|
201 | <th>${_('Prefix')}</th> | |||
|
202 | <th>${_('Key')}</th> | |||
|
203 | <th>${_('Active')}</th> | |||
|
204 | </tr> | |||
200 | %for cache in c.repo_info.cache_keys: |
|
205 | %for cache in c.repo_info.cache_keys: | |
201 | <li>INSTANCE ID:${cache.prefix or '-'} ${cache.cache_args} CACHED: ${h.bool2icon(cache.cache_active)}</li> |
|
206 | <tr> | |
|
207 | <td>${cache.prefix or '-'}</td> | |||
|
208 | <td>${cache.cache_key}</td> | |||
|
209 | <td>${h.bool2icon(cache.cache_active)}</td> | |||
|
210 | </tr> | |||
202 | %endfor |
|
211 | %endfor | |
203 |
</ |
|
212 | </table> | |
204 | </div> |
|
213 | </div> | |
205 | </div> |
|
214 | </div> | |
206 | </div> |
|
215 | </div> |
General Comments 0
You need to be logged in to leave comments.
Login now