Mercurial > kallithea
comparison 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 |
comparison
equal
deleted
inserted
replaced
170:f9e8920958af | 171:52bbeb1e813f |
---|---|
88 for k, v in cfg.items(section): | 88 for k, v in cfg.items(section): |
89 baseui.setconfig(section, k, v) | 89 baseui.setconfig(section, k, v) |
90 | 90 |
91 return baseui | 91 return baseui |
92 | 92 |
93 def invalidate_cache(name): | 93 def invalidate_cache(name, *args): |
94 from beaker.cache import region_invalidate | 94 from beaker.cache import region_invalidate |
95 if name == 'repo_list_2': | 95 log.info('INVALIDATING CACHE FOR %s', name) |
96 log.info('INVALIDATING CACHE FOR %s', name) | 96 |
97 from pylons_app.lib.base import _get_repos | 97 """propaget our arguments to make sure invalidation works. First |
98 #clear our cached list for refresh with new repo | 98 argument has to be the name of cached func name give to cache decorator |
99 region_invalidate(_get_repos, None, 'repo_list_2') | 99 without that the invalidation would not work""" |
100 | 100 tmp = [name] |
101 tmp.extend(args) | |
102 args = tuple(tmp) | |
103 | |
104 if name == 'cached_repo_list': | |
105 from pylons_app.lib.base import _get_repos_cached | |
106 region_invalidate(_get_repos_cached, None, *args) | |
107 | |
108 if name == 'full_changelog': | |
109 from pylons_app.controllers.changelog import _full_changelog_cached | |
110 region_invalidate(_full_changelog_cached, None, *args) | |
111 | |
101 from vcs.backends.base import BaseChangeset | 112 from vcs.backends.base import BaseChangeset |
102 from vcs.utils.lazy import LazyProperty | 113 from vcs.utils.lazy import LazyProperty |
103 class EmptyChangeset(BaseChangeset): | 114 class EmptyChangeset(BaseChangeset): |
104 | 115 |
105 revision = -1 | 116 revision = -1 |