cache: turn off caches if expiration_time is 0
This commit is contained in:
parent
cc72ded271
commit
6be51bb03d
2 changed files with 33 additions and 4 deletions
|
|
@ -30,6 +30,7 @@ from pyramid.view import view_config
|
|||
from pyramid.renderers import render
|
||||
from pyramid.response import Response
|
||||
|
||||
import rhodecode
|
||||
from rhodecode.apps._base import RepoAppView
|
||||
|
||||
from rhodecode.controllers.utils import parse_path_ref
|
||||
|
|
@ -39,7 +40,7 @@ from rhodecode.lib.exceptions import NonRelativePathError
|
|||
from rhodecode.lib.codeblocks import (
|
||||
filenode_as_lines_tokens, filenode_as_annotated_lines_tokens)
|
||||
from rhodecode.lib.utils2 import (
|
||||
convert_line_endings, detect_mode, safe_str, str2bool)
|
||||
convert_line_endings, detect_mode, safe_str, str2bool, safe_int)
|
||||
from rhodecode.lib.auth import (
|
||||
LoginRequired, HasRepoPermissionAnyDecorator, CSRFRequired)
|
||||
from rhodecode.lib.vcs import path as vcspath
|
||||
|
|
@ -192,10 +193,19 @@ class RepoFilesView(RepoAppView):
|
|||
|
||||
repo_id = self.db_repo.repo_id
|
||||
|
||||
cache_seconds = safe_int(
|
||||
rhodecode.CONFIG.get('rc_cache.cache_repo.expiration_time'))
|
||||
cache_on = cache_seconds > 0
|
||||
log.debug(
|
||||
'Computing FILE TREE for repo_id %s commit_id `%s` and path `%s`'
|
||||
'with caching: %s[TTL: %ss]' % (
|
||||
repo_id, commit_id, f_path, cache_on, cache_seconds or 0))
|
||||
|
||||
cache_namespace_uid = 'cache_repo.{}'.format(repo_id)
|
||||
region = rc_cache.get_or_create_region('cache_repo', cache_namespace_uid)
|
||||
|
||||
@region.cache_on_arguments(namespace=cache_namespace_uid)
|
||||
@region.cache_on_arguments(namespace=cache_namespace_uid,
|
||||
should_cache_fn=lambda v: cache_on)
|
||||
def compute_file_tree(repo_id, commit_id, f_path, full_load):
|
||||
log.debug('Generating cached file tree for repo_id: %s, %s, %s',
|
||||
repo_id, commit_id, f_path)
|
||||
|
|
@ -775,10 +785,19 @@ class RepoFilesView(RepoAppView):
|
|||
|
||||
def _get_nodelist_at_commit(self, repo_name, repo_id, commit_id, f_path):
|
||||
|
||||
cache_seconds = safe_int(
|
||||
rhodecode.CONFIG.get('rc_cache.cache_repo.expiration_time'))
|
||||
cache_on = cache_seconds > 0
|
||||
log.debug(
|
||||
'Computing FILE SEARCH for repo_id %s commit_id `%s` and path `%s`'
|
||||
'with caching: %s[TTL: %ss]' % (
|
||||
repo_id, commit_id, f_path, cache_on, cache_seconds or 0))
|
||||
|
||||
cache_namespace_uid = 'cache_repo.{}'.format(repo_id)
|
||||
region = rc_cache.get_or_create_region('cache_repo', cache_namespace_uid)
|
||||
|
||||
@region.cache_on_arguments(namespace=cache_namespace_uid)
|
||||
@region.cache_on_arguments(namespace=cache_namespace_uid,
|
||||
should_cache_fn=lambda v: cache_on)
|
||||
def compute_file_search(repo_id, commit_id, f_path):
|
||||
log.debug('Generating cached nodelist for repo_id:%s, %s, %s',
|
||||
repo_id, commit_id, f_path)
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@
|
|||
|
||||
import logging
|
||||
import string
|
||||
import rhodecode
|
||||
|
||||
from pyramid.view import view_config
|
||||
from beaker.cache import cache_region
|
||||
|
|
@ -249,10 +250,19 @@ class RepoSummaryView(RepoAppView):
|
|||
show_stats = bool(self.db_repo.enable_statistics)
|
||||
repo_id = self.db_repo.repo_id
|
||||
|
||||
cache_seconds = safe_int(
|
||||
rhodecode.CONFIG.get('rc_cache.cache_repo.expiration_time'))
|
||||
cache_on = cache_seconds > 0
|
||||
log.debug(
|
||||
'Computing REPO TREE for repo_id %s commit_id `%s` '
|
||||
'with caching: %s[TTL: %ss]' % (
|
||||
repo_id, commit_id, cache_on, cache_seconds or 0))
|
||||
|
||||
cache_namespace_uid = 'cache_repo.{}'.format(repo_id)
|
||||
region = rc_cache.get_or_create_region('cache_repo', cache_namespace_uid)
|
||||
|
||||
@region.cache_on_arguments(namespace=cache_namespace_uid)
|
||||
@region.cache_on_arguments(namespace=cache_namespace_uid,
|
||||
should_cache_fn=lambda v: cache_on)
|
||||
def compute_stats(repo_id, commit_id, show_stats):
|
||||
code_stats = {}
|
||||
size = 0
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue