Changeset - 21cccfea18bf
[Not reviewed]
beta
0 2 0
Marcin Kuzminski - 13 years ago 2013-01-26 23:11:40
marcin@python-works.com
Return a list of invlidated keys on mark_for_invalidation func
- log.debug list of invalidated keys
2 files changed with 7 insertions and 3 deletions:
0 comments (0 inline, 0 general)
rhodecode/model/db.py
Show inline comments
 
@@ -1653,22 +1653,25 @@ class CacheInvalidation(Base, BaseModel)
 

	
 
        :param key:
 
        """
 
        invalidated_keys = []
 
        if key:
 
            key, _prefix, _org_key = cls._get_key(key)
 
            inv_objs = Session().query(cls).filter(cls.cache_key == key).all()
 
        elif repo_name:
 
            inv_objs = Session().query(cls).filter(cls.cache_args == repo_name).all()
 

	
 
        log.debug('marking %s key[s] for invalidation based on key=%s,repo_name=%s'
 
                  % (len(inv_objs), key, repo_name))
 
        try:
 
            for inv_obj in inv_objs:
 
                inv_obj.cache_active = False
 
                log.debug('marking %s key for invalidation based on key=%s,repo_name=%s'
 
                  % (inv_obj, key, repo_name))
 
                invalidated_keys.append(inv_obj.cache_key)
 
                Session().add(inv_obj)
 
            Session().commit()
 
        except Exception:
 
            log.error(traceback.format_exc())
 
            Session().rollback()
 
        return invalidated_keys
 

	
 
    @classmethod
 
    def set_valid(cls, key):
rhodecode/model/scm.py
Show inline comments
 
@@ -301,10 +301,11 @@ class ScmModel(BaseModel):
 

	
 
        :param repo_name: this repo that should invalidation take place
 
        """
 
        CacheInvalidation.set_invalidate(repo_name=repo_name)
 
        invalidated_keys = CacheInvalidation.set_invalidate(repo_name=repo_name)
 
        repo = Repository.get_by_repo_name(repo_name)
 
        if repo:
 
            repo.update_changeset_cache()
 
        return invalidated_keys
 

	
 
    def toggle_following_repo(self, follow_repo_id, user_id):
 

	
0 comments (0 inline, 0 general)