# HG changeset patch # User Mads Kiilerich # Date 2013-04-03 13:56:12 # Node ID 02e1e270bf93ef4bd56f94299ccef0a126155651 # Parent e8aff2016d869bbfd20913422e0162f4047bde12 invalidation: set_invalidate is (obviously) only used to invalidate the whole repo diff --git a/rhodecode/model/db.py b/rhodecode/model/db.py --- a/rhodecode/model/db.py +++ b/rhodecode/model/db.py @@ -1697,27 +1697,18 @@ class CacheInvalidation(Base, BaseModel) return inv_obj @classmethod - def set_invalidate(cls, key=None, repo_name=None): + def set_invalidate(cls, repo_name): """ - Mark this Cache key for invalidation, either by key or whole - cache sets based on repo_name - - :param key: + Mark all caches of a repo as invalid in the database. """ invalidated_keys = [] - if key: - assert not repo_name - cache_key = cls._get_cache_key(key) - inv_objs = Session().query(cls).filter(cls.cache_key == cache_key).all() - else: - assert repo_name - inv_objs = Session().query(cls).filter(cls.cache_args == repo_name).all() + inv_objs = Session().query(cls).filter(cls.cache_args == repo_name).all() try: for inv_obj in inv_objs: + log.debug('marking %s key for invalidation based on repo_name=%s' + % (inv_obj, safe_str(repo_name))) inv_obj.cache_active = False - log.debug('marking %s key for invalidation based on key=%s,repo_name=%s' - % (inv_obj, key, safe_str(repo_name))) invalidated_keys.append(inv_obj.cache_key) Session().add(inv_obj) Session().commit() diff --git a/rhodecode/model/scm.py b/rhodecode/model/scm.py --- a/rhodecode/model/scm.py +++ b/rhodecode/model/scm.py @@ -301,7 +301,7 @@ class ScmModel(BaseModel): :param repo_name: the repo for which caches should be marked invalid """ - invalidated_keys = CacheInvalidation.set_invalidate(repo_name=repo_name) + invalidated_keys = CacheInvalidation.set_invalidate(repo_name) repo = Repository.get_by_repo_name(repo_name) if repo: repo.update_changeset_cache()