##// END OF EJS Templates
invalidate: clear CacheInvalidation when upgrading
Mads Kiilerich -
r3757:f08881dc beta
parent child Browse files
Show More
@@ -37,7 +37,7 b' from rhodecode.lib.utils import ask_ok'
37 from rhodecode.model import init_model
37 from rhodecode.model import init_model
38 from rhodecode.model.db import User, Permission, RhodeCodeUi, \
38 from rhodecode.model.db import User, Permission, RhodeCodeUi, \
39 RhodeCodeSetting, UserToPerm, DbMigrateVersion, RepoGroup, \
39 RhodeCodeSetting, UserToPerm, DbMigrateVersion, RepoGroup, \
40 UserRepoGroupToPerm
40 UserRepoGroupToPerm, CacheInvalidation
41
41
42 from sqlalchemy.engine import create_engine
42 from sqlalchemy.engine import create_engine
43 from rhodecode.model.repos_group import ReposGroupModel
43 from rhodecode.model.repos_group import ReposGroupModel
@@ -150,6 +150,10 b' class DbManage(object):'
150 if curr_version == __dbversion__:
150 if curr_version == __dbversion__:
151 sys.exit('This database is already at the newest version')
151 sys.exit('This database is already at the newest version')
152
152
153 # clear cache keys
154 log.info("Clearing cache keys now...")
155 CacheInvalidation.clear_cache()
156
153 #======================================================================
157 #======================================================================
154 # UPGRADE STEPS
158 # UPGRADE STEPS
155 #======================================================================
159 #======================================================================
@@ -1806,6 +1806,15 b' class CacheInvalidation(Base, BaseModel)'
1806 return self._cache_key_partition()[2]
1806 return self._cache_key_partition()[2]
1807
1807
1808 @classmethod
1808 @classmethod
1809 def clear_cache(cls):
1810 """
1811 Delete all cache keys from database.
1812 Should only be run when all instances are down and all entries thus stale.
1813 """
1814 cls.query().delete()
1815 Session().commit()
1816
1817 @classmethod
1809 def _get_cache_key(cls, key):
1818 def _get_cache_key(cls, key):
1810 """
1819 """
1811 Wrapper for generating a unique cache key for this instance and "key".
1820 Wrapper for generating a unique cache key for this instance and "key".
General Comments 0
You need to be logged in to leave comments. Login now