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
 
@@ -34,13 +34,13 @@ from rhodecode import __dbversion__, __p
 

	
 
from rhodecode.model.user import UserModel
 
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
 
#from rhodecode.model import meta
 
from rhodecode.model.meta import Session, Base
 
from rhodecode.model.repo import RepoModel
 
@@ -147,12 +147,16 @@ class DbManage(object):
 

	
 
        notify(msg)
 

	
 
        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
 
        #======================================================================
 

	
 
        class UpgradeSteps(object):
 
            """
rhodecode/model/db.py
Show inline comments
 
@@ -1803,12 +1803,21 @@ class CacheInvalidation(Base, BaseModel)
 
        in repo_edit.html.
 
        """
 
        # prefix, repo_name, suffix
 
        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".
 
        key must / will start with a repo_name which will be stored in .cache_args .
 
        """
 
        import rhodecode
0 comments (0 inline, 0 general)