##// END OF EJS Templates
Return a list of invlidated keys on mark_for_invalidation func...
marcink -
r3234:21cccfea beta
parent child Browse files
Show More
@@ -1653,22 +1653,25 b' class CacheInvalidation(Base, BaseModel)'
1653
1653
1654 :param key:
1654 :param key:
1655 """
1655 """
1656 invalidated_keys = []
1656 if key:
1657 if key:
1657 key, _prefix, _org_key = cls._get_key(key)
1658 key, _prefix, _org_key = cls._get_key(key)
1658 inv_objs = Session().query(cls).filter(cls.cache_key == key).all()
1659 inv_objs = Session().query(cls).filter(cls.cache_key == key).all()
1659 elif repo_name:
1660 elif repo_name:
1660 inv_objs = Session().query(cls).filter(cls.cache_args == repo_name).all()
1661 inv_objs = Session().query(cls).filter(cls.cache_args == repo_name).all()
1661
1662
1662 log.debug('marking %s key[s] for invalidation based on key=%s,repo_name=%s'
1663 % (len(inv_objs), key, repo_name))
1664 try:
1663 try:
1665 for inv_obj in inv_objs:
1664 for inv_obj in inv_objs:
1666 inv_obj.cache_active = False
1665 inv_obj.cache_active = False
1666 log.debug('marking %s key for invalidation based on key=%s,repo_name=%s'
1667 % (inv_obj, key, repo_name))
1668 invalidated_keys.append(inv_obj.cache_key)
1667 Session().add(inv_obj)
1669 Session().add(inv_obj)
1668 Session().commit()
1670 Session().commit()
1669 except Exception:
1671 except Exception:
1670 log.error(traceback.format_exc())
1672 log.error(traceback.format_exc())
1671 Session().rollback()
1673 Session().rollback()
1674 return invalidated_keys
1672
1675
1673 @classmethod
1676 @classmethod
1674 def set_valid(cls, key):
1677 def set_valid(cls, key):
@@ -301,10 +301,11 b' class ScmModel(BaseModel):'
301
301
302 :param repo_name: this repo that should invalidation take place
302 :param repo_name: this repo that should invalidation take place
303 """
303 """
304 CacheInvalidation.set_invalidate(repo_name=repo_name)
304 invalidated_keys = CacheInvalidation.set_invalidate(repo_name=repo_name)
305 repo = Repository.get_by_repo_name(repo_name)
305 repo = Repository.get_by_repo_name(repo_name)
306 if repo:
306 if repo:
307 repo.update_changeset_cache()
307 repo.update_changeset_cache()
308 return invalidated_keys
308
309
309 def toggle_following_repo(self, follow_repo_id, user_id):
310 def toggle_following_repo(self, follow_repo_id, user_id):
310
311
General Comments 0
You need to be logged in to leave comments. Login now