changeset 3685:02e1e270bf93 beta

invalidation: set_invalidate is (obviously) only used to invalidate the whole repo
author Mads Kiilerich <madski@unity3d.com>
date Wed, 03 Apr 2013 15:56:12 +0200
parents e8aff2016d86
children f18801f827da
files rhodecode/model/db.py rhodecode/model/scm.py
diffstat 2 files changed, 6 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/rhodecode/model/db.py	Thu Apr 04 15:55:53 2013 +0200
+++ b/rhodecode/model/db.py	Wed Apr 03 15:56:12 2013 +0200
@@ -1697,27 +1697,18 @@
             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()
--- a/rhodecode/model/scm.py	Thu Apr 04 15:55:53 2013 +0200
+++ b/rhodecode/model/scm.py	Wed Apr 03 15:56:12 2013 +0200
@@ -301,7 +301,7 @@
 
         :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()