Mercurial > kallithea
diff pylons_app/lib/utils.py @ 171:52bbeb1e813f
Added universal cache invalidator for two cached functions.
added invalidation when repository was added or deleted, and another invalidation when there was a mercurial command involved.
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Fri, 21 May 2010 02:44:40 +0200 |
parents | b5e59e2b5cfe |
children | 50a39f923f31 |
line wrap: on
line diff
--- a/pylons_app/lib/utils.py Fri May 21 02:18:54 2010 +0200 +++ b/pylons_app/lib/utils.py Fri May 21 02:44:40 2010 +0200 @@ -90,14 +90,25 @@ return baseui -def invalidate_cache(name): +def invalidate_cache(name, *args): from beaker.cache import region_invalidate - if name == 'repo_list_2': - log.info('INVALIDATING CACHE FOR %s', name) - from pylons_app.lib.base import _get_repos - #clear our cached list for refresh with new repo - region_invalidate(_get_repos, None, 'repo_list_2') - + log.info('INVALIDATING CACHE FOR %s', name) + + """propaget our arguments to make sure invalidation works. First + argument has to be the name of cached func name give to cache decorator + without that the invalidation would not work""" + tmp = [name] + tmp.extend(args) + args = tuple(tmp) + + if name == 'cached_repo_list': + from pylons_app.lib.base import _get_repos_cached + region_invalidate(_get_repos_cached, None, *args) + + if name == 'full_changelog': + from pylons_app.controllers.changelog import _full_changelog_cached + region_invalidate(_full_changelog_cached, None, *args) + from vcs.backends.base import BaseChangeset from vcs.utils.lazy import LazyProperty class EmptyChangeset(BaseChangeset):