changeset 3234:21cccfea18bf beta

Return a list of invlidated keys on mark_for_invalidation func - log.debug list of invalidated keys
author Marcin Kuzminski <marcin@python-works.com>
date Sat, 26 Jan 2013 23:11:40 +0100
parents 11b005b2d5e8
children d6029dacbcc4
files rhodecode/model/db.py rhodecode/model/scm.py
diffstat 2 files changed, 7 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/rhodecode/model/db.py	Sat Jan 26 22:32:25 2013 +0100
+++ b/rhodecode/model/db.py	Sat Jan 26 23:11:40 2013 +0100
@@ -1653,22 +1653,25 @@
 
         :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):
--- a/rhodecode/model/scm.py	Sat Jan 26 22:32:25 2013 +0100
+++ b/rhodecode/model/scm.py	Sat Jan 26 23:11:40 2013 +0100
@@ -301,10 +301,11 @@
 
         :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):