##// END OF EJS Templates
cache: turn off caches if expiration_time is 0
marcink -
r2848:daea8b54 default
parent child Browse files
Show More
@@ -30,6 +30,7 b' from pyramid.view import view_config'
30 30 from pyramid.renderers import render
31 31 from pyramid.response import Response
32 32
33 import rhodecode
33 34 from rhodecode.apps._base import RepoAppView
34 35
35 36 from rhodecode.controllers.utils import parse_path_ref
@@ -39,7 +40,7 b' from rhodecode.lib.exceptions import Non'
39 40 from rhodecode.lib.codeblocks import (
40 41 filenode_as_lines_tokens, filenode_as_annotated_lines_tokens)
41 42 from rhodecode.lib.utils2 import (
42 convert_line_endings, detect_mode, safe_str, str2bool)
43 convert_line_endings, detect_mode, safe_str, str2bool, safe_int)
43 44 from rhodecode.lib.auth import (
44 45 LoginRequired, HasRepoPermissionAnyDecorator, CSRFRequired)
45 46 from rhodecode.lib.vcs import path as vcspath
@@ -192,10 +193,19 b' class RepoFilesView(RepoAppView):'
192 193
193 194 repo_id = self.db_repo.repo_id
194 195
196 cache_seconds = safe_int(
197 rhodecode.CONFIG.get('rc_cache.cache_repo.expiration_time'))
198 cache_on = cache_seconds > 0
199 log.debug(
200 'Computing FILE TREE for repo_id %s commit_id `%s` and path `%s`'
201 'with caching: %s[TTL: %ss]' % (
202 repo_id, commit_id, f_path, cache_on, cache_seconds or 0))
203
195 204 cache_namespace_uid = 'cache_repo.{}'.format(repo_id)
196 205 region = rc_cache.get_or_create_region('cache_repo', cache_namespace_uid)
197 206
198 @region.cache_on_arguments(namespace=cache_namespace_uid)
207 @region.cache_on_arguments(namespace=cache_namespace_uid,
208 should_cache_fn=lambda v: cache_on)
199 209 def compute_file_tree(repo_id, commit_id, f_path, full_load):
200 210 log.debug('Generating cached file tree for repo_id: %s, %s, %s',
201 211 repo_id, commit_id, f_path)
@@ -775,10 +785,19 b' class RepoFilesView(RepoAppView):'
775 785
776 786 def _get_nodelist_at_commit(self, repo_name, repo_id, commit_id, f_path):
777 787
788 cache_seconds = safe_int(
789 rhodecode.CONFIG.get('rc_cache.cache_repo.expiration_time'))
790 cache_on = cache_seconds > 0
791 log.debug(
792 'Computing FILE SEARCH for repo_id %s commit_id `%s` and path `%s`'
793 'with caching: %s[TTL: %ss]' % (
794 repo_id, commit_id, f_path, cache_on, cache_seconds or 0))
795
778 796 cache_namespace_uid = 'cache_repo.{}'.format(repo_id)
779 797 region = rc_cache.get_or_create_region('cache_repo', cache_namespace_uid)
780 798
781 @region.cache_on_arguments(namespace=cache_namespace_uid)
799 @region.cache_on_arguments(namespace=cache_namespace_uid,
800 should_cache_fn=lambda v: cache_on)
782 801 def compute_file_search(repo_id, commit_id, f_path):
783 802 log.debug('Generating cached nodelist for repo_id:%s, %s, %s',
784 803 repo_id, commit_id, f_path)
@@ -20,6 +20,7 b''
20 20
21 21 import logging
22 22 import string
23 import rhodecode
23 24
24 25 from pyramid.view import view_config
25 26 from beaker.cache import cache_region
@@ -249,10 +250,19 b' class RepoSummaryView(RepoAppView):'
249 250 show_stats = bool(self.db_repo.enable_statistics)
250 251 repo_id = self.db_repo.repo_id
251 252
253 cache_seconds = safe_int(
254 rhodecode.CONFIG.get('rc_cache.cache_repo.expiration_time'))
255 cache_on = cache_seconds > 0
256 log.debug(
257 'Computing REPO TREE for repo_id %s commit_id `%s` '
258 'with caching: %s[TTL: %ss]' % (
259 repo_id, commit_id, cache_on, cache_seconds or 0))
260
252 261 cache_namespace_uid = 'cache_repo.{}'.format(repo_id)
253 262 region = rc_cache.get_or_create_region('cache_repo', cache_namespace_uid)
254 263
255 @region.cache_on_arguments(namespace=cache_namespace_uid)
264 @region.cache_on_arguments(namespace=cache_namespace_uid,
265 should_cache_fn=lambda v: cache_on)
256 266 def compute_stats(repo_id, commit_id, show_stats):
257 267 code_stats = {}
258 268 size = 0
General Comments 0
You need to be logged in to leave comments. Login now