Changeset - 02e1e270bf93
[Not reviewed]
beta
0 2 0
Mads Kiilerich - 13 years ago 2013-04-03 15:56:12
madski@unity3d.com
Transplanted from: aac5b0a5a606
invalidation: set_invalidate is (obviously) only used to invalidate the whole repo
2 files changed with 5 insertions and 14 deletions:
0 comments (0 inline, 0 general)
rhodecode/model/db.py
Show inline comments
 
@@ -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()
 

	
 
        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()
rhodecode/model/scm.py
Show inline comments
 
@@ -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()
0 comments (0 inline, 0 general)