Show More
@@ -30,6 +30,7 b' from pyramid.view import view_config' | |||||
30 | from pyramid.renderers import render |
|
30 | from pyramid.renderers import render | |
31 | from pyramid.response import Response |
|
31 | from pyramid.response import Response | |
32 |
|
32 | |||
|
33 | import rhodecode | |||
33 | from rhodecode.apps._base import RepoAppView |
|
34 | from rhodecode.apps._base import RepoAppView | |
34 |
|
35 | |||
35 | from rhodecode.controllers.utils import parse_path_ref |
|
36 | from rhodecode.controllers.utils import parse_path_ref | |
@@ -39,7 +40,7 b' from rhodecode.lib.exceptions import Non' | |||||
39 | from rhodecode.lib.codeblocks import ( |
|
40 | from rhodecode.lib.codeblocks import ( | |
40 | filenode_as_lines_tokens, filenode_as_annotated_lines_tokens) |
|
41 | filenode_as_lines_tokens, filenode_as_annotated_lines_tokens) | |
41 | from rhodecode.lib.utils2 import ( |
|
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 | from rhodecode.lib.auth import ( |
|
44 | from rhodecode.lib.auth import ( | |
44 | LoginRequired, HasRepoPermissionAnyDecorator, CSRFRequired) |
|
45 | LoginRequired, HasRepoPermissionAnyDecorator, CSRFRequired) | |
45 | from rhodecode.lib.vcs import path as vcspath |
|
46 | from rhodecode.lib.vcs import path as vcspath | |
@@ -192,10 +193,19 b' class RepoFilesView(RepoAppView):' | |||||
192 |
|
193 | |||
193 | repo_id = self.db_repo.repo_id |
|
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 | cache_namespace_uid = 'cache_repo.{}'.format(repo_id) |
|
204 | cache_namespace_uid = 'cache_repo.{}'.format(repo_id) | |
196 | region = rc_cache.get_or_create_region('cache_repo', cache_namespace_uid) |
|
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 | def compute_file_tree(repo_id, commit_id, f_path, full_load): |
|
209 | def compute_file_tree(repo_id, commit_id, f_path, full_load): | |
200 | log.debug('Generating cached file tree for repo_id: %s, %s, %s', |
|
210 | log.debug('Generating cached file tree for repo_id: %s, %s, %s', | |
201 | repo_id, commit_id, f_path) |
|
211 | repo_id, commit_id, f_path) | |
@@ -775,10 +785,19 b' class RepoFilesView(RepoAppView):' | |||||
775 |
|
785 | |||
776 | def _get_nodelist_at_commit(self, repo_name, repo_id, commit_id, f_path): |
|
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 | cache_namespace_uid = 'cache_repo.{}'.format(repo_id) |
|
796 | cache_namespace_uid = 'cache_repo.{}'.format(repo_id) | |
779 | region = rc_cache.get_or_create_region('cache_repo', cache_namespace_uid) |
|
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 | def compute_file_search(repo_id, commit_id, f_path): |
|
801 | def compute_file_search(repo_id, commit_id, f_path): | |
783 | log.debug('Generating cached nodelist for repo_id:%s, %s, %s', |
|
802 | log.debug('Generating cached nodelist for repo_id:%s, %s, %s', | |
784 | repo_id, commit_id, f_path) |
|
803 | repo_id, commit_id, f_path) |
@@ -20,6 +20,7 b'' | |||||
20 |
|
20 | |||
21 | import logging |
|
21 | import logging | |
22 | import string |
|
22 | import string | |
|
23 | import rhodecode | |||
23 |
|
24 | |||
24 | from pyramid.view import view_config |
|
25 | from pyramid.view import view_config | |
25 | from beaker.cache import cache_region |
|
26 | from beaker.cache import cache_region | |
@@ -249,10 +250,19 b' class RepoSummaryView(RepoAppView):' | |||||
249 | show_stats = bool(self.db_repo.enable_statistics) |
|
250 | show_stats = bool(self.db_repo.enable_statistics) | |
250 | repo_id = self.db_repo.repo_id |
|
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 | cache_namespace_uid = 'cache_repo.{}'.format(repo_id) |
|
261 | cache_namespace_uid = 'cache_repo.{}'.format(repo_id) | |
253 | region = rc_cache.get_or_create_region('cache_repo', cache_namespace_uid) |
|
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 | def compute_stats(repo_id, commit_id, show_stats): |
|
266 | def compute_stats(repo_id, commit_id, show_stats): | |
257 | code_stats = {} |
|
267 | code_stats = {} | |
258 | size = 0 |
|
268 | size = 0 |
General Comments 0
You need to be logged in to leave comments.
Login now