Mercurial > kallithea
comparison rhodecode/model/db.py @ 3018:023f7873ef59 beta
added caching layer into RSS/ATOM feeds
- updated code for new LimitedDiffContainers
- invalidate rss/atom cache keys on push
-
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Fri, 23 Nov 2012 11:54:14 +0100 |
parents | 78227b65a358 |
children | 00498b3e4c88 |
comparison
equal
deleted
inserted
replaced
3017:eaa36a2497a9 | 3018:023f7873ef59 |
---|---|
44 from rhodecode.lib.vcs.utils.helpers import get_scm | 44 from rhodecode.lib.vcs.utils.helpers import get_scm |
45 from rhodecode.lib.vcs.exceptions import VCSError | 45 from rhodecode.lib.vcs.exceptions import VCSError |
46 from rhodecode.lib.vcs.utils.lazy import LazyProperty | 46 from rhodecode.lib.vcs.utils.lazy import LazyProperty |
47 | 47 |
48 from rhodecode.lib.utils2 import str2bool, safe_str, get_changeset_safe, \ | 48 from rhodecode.lib.utils2 import str2bool, safe_str, get_changeset_safe, \ |
49 safe_unicode | 49 safe_unicode, remove_suffix |
50 from rhodecode.lib.compat import json | 50 from rhodecode.lib.compat import json |
51 from rhodecode.lib.caching_query import FromCache | 51 from rhodecode.lib.caching_query import FromCache |
52 | 52 |
53 from rhodecode.model.meta import Base, Session | 53 from rhodecode.model.meta import Base, Session |
54 | 54 |
939 """ | 939 """ |
940 CacheInvalidation.set_invalidate(self.repo_name) | 940 CacheInvalidation.set_invalidate(self.repo_name) |
941 | 941 |
942 @LazyProperty | 942 @LazyProperty |
943 def scm_instance(self): | 943 def scm_instance(self): |
944 return self.scm_instance_cached() | |
944 return self.__get_instance() | 945 return self.__get_instance() |
945 | 946 |
946 def scm_instance_cached(self, cache_map=None): | 947 def scm_instance_cached(self, cache_map=None): |
947 @cache_region('long_term') | 948 @cache_region('long_term') |
948 def _c(repo_name): | 949 def _c(repo_name): |
1438 import rhodecode | 1439 import rhodecode |
1439 prefix = '' | 1440 prefix = '' |
1440 iid = rhodecode.CONFIG.get('instance_id') | 1441 iid = rhodecode.CONFIG.get('instance_id') |
1441 if iid: | 1442 if iid: |
1442 prefix = iid | 1443 prefix = iid |
1443 return "%s%s" % (prefix, key), prefix, key.rstrip('_README') | 1444 #remove specific suffixes like _README or _RSS |
1445 key = remove_suffix(key, '_README') | |
1446 key = remove_suffix(key, '_RSS') | |
1447 key = remove_suffix(key, '_ATOM') | |
1448 return "%s%s" % (prefix, key), prefix, key | |
1444 | 1449 |
1445 @classmethod | 1450 @classmethod |
1446 def get_by_key(cls, key): | 1451 def get_by_key(cls, key): |
1447 return cls.query().filter(cls.cache_key == key).scalar() | 1452 return cls.query().filter(cls.cache_key == key).scalar() |
1448 | 1453 |