Changeset - f08881dcc9eb
[Not reviewed]
beta
0 2 0
Mads Kiilerich - 13 years ago 2013-04-03 15:56:12
madski@unity3d.com
Grafted from: ec0290e0109f
invalidate: clear CacheInvalidation when upgrading
2 files changed with 14 insertions and 1 deletions:
0 comments (0 inline, 0 general)
rhodecode/lib/db_manage.py
Show inline comments
 
@@ -37,7 +37,7 @@ from rhodecode.lib.utils import ask_ok
 
from rhodecode.model import init_model
 
from rhodecode.model.db import User, Permission, RhodeCodeUi, \
 
    RhodeCodeSetting, UserToPerm, DbMigrateVersion, RepoGroup, \
 
    UserRepoGroupToPerm
 
    UserRepoGroupToPerm, CacheInvalidation
 

	
 
from sqlalchemy.engine import create_engine
 
from rhodecode.model.repos_group import ReposGroupModel
 
@@ -150,6 +150,10 @@ class DbManage(object):
 
        if curr_version == __dbversion__:
 
            sys.exit('This database is already at the newest version')
 

	
 
        # clear cache keys
 
        log.info("Clearing cache keys now...")
 
        CacheInvalidation.clear_cache()
 

	
 
        #======================================================================
 
        # UPGRADE STEPS
 
        #======================================================================
rhodecode/model/db.py
Show inline comments
 
@@ -1806,6 +1806,15 @@ class CacheInvalidation(Base, BaseModel)
 
        return self._cache_key_partition()[2]
 

	
 
    @classmethod
 
    def clear_cache(cls):
 
        """
 
        Delete all cache keys from database.
 
        Should only be run when all instances are down and all entries thus stale.
 
        """
 
        cls.query().delete()
 
        Session().commit()
 

	
 
    @classmethod
 
    def _get_cache_key(cls, key):
 
        """
 
        Wrapper for generating a unique cache key for this instance and "key".
0 comments (0 inline, 0 general)