##// END OF EJS Templates
caches: use new decorator that uses conditional caches skipping dogpile if cache is disabled.
marcink -
r2892:c633266d default
parent child Browse files
Show More
@@ -204,8 +204,8 b' class RepoFilesView(RepoAppView):'
204 cache_namespace_uid = 'cache_repo.{}'.format(repo_id)
204 cache_namespace_uid = 'cache_repo.{}'.format(repo_id)
205 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)
206
206
207 @region.cache_on_arguments(namespace=cache_namespace_uid,
207 @region.conditional_cache_on_arguments(namespace=cache_namespace_uid,
208 should_cache_fn=lambda v: cache_on)
208 condition=cache_on)
209 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):
210 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',
211 repo_id, commit_id, f_path)
211 repo_id, commit_id, f_path)
@@ -796,8 +796,8 b' class RepoFilesView(RepoAppView):'
796 cache_namespace_uid = 'cache_repo.{}'.format(repo_id)
796 cache_namespace_uid = 'cache_repo.{}'.format(repo_id)
797 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)
798
798
799 @region.cache_on_arguments(namespace=cache_namespace_uid,
799 @region.conditional_cache_on_arguments(namespace=cache_namespace_uid,
800 should_cache_fn=lambda v: cache_on)
800 condition=cache_on)
801 def compute_file_search(repo_id, commit_id, f_path):
801 def compute_file_search(repo_id, commit_id, f_path):
802 log.debug('Generating cached nodelist for repo_id:%s, %s, %s',
802 log.debug('Generating cached nodelist for repo_id:%s, %s, %s',
803 repo_id, commit_id, f_path)
803 repo_id, commit_id, f_path)
@@ -261,8 +261,8 b' class RepoSummaryView(RepoAppView):'
261 cache_namespace_uid = 'cache_repo.{}'.format(repo_id)
261 cache_namespace_uid = 'cache_repo.{}'.format(repo_id)
262 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)
263
263
264 @region.cache_on_arguments(namespace=cache_namespace_uid,
264 @region.conditional_cache_on_arguments(namespace=cache_namespace_uid,
265 should_cache_fn=lambda v: cache_on)
265 condition=cache_on)
266 def compute_stats(repo_id, commit_id, show_stats):
266 def compute_stats(repo_id, commit_id, show_stats):
267 code_stats = {}
267 code_stats = {}
268 size = 0
268 size = 0
@@ -700,9 +700,9 b' def authenticate(username, password, env'
700 cache_namespace_uid = 'cache_user_auth.{}'.format(user_id)
700 cache_namespace_uid = 'cache_user_auth.{}'.format(user_id)
701 region = rc_cache.get_or_create_region('cache_perms', cache_namespace_uid)
701 region = rc_cache.get_or_create_region('cache_perms', cache_namespace_uid)
702
702
703 @region.cache_on_arguments(namespace=cache_namespace_uid,
703 @region.conditional_cache_on_arguments(namespace=cache_namespace_uid,
704 expiration_time=cache_ttl,
704 expiration_time=cache_ttl,
705 should_cache_fn=lambda v: plugin_cache_active)
705 condition=plugin_cache_active)
706 def compute_auth(
706 def compute_auth(
707 cache_name, plugin_name, username, password):
707 cache_name, plugin_name, username, password):
708
708
@@ -1079,8 +1079,8 b' class AuthUser(object):'
1079 cache_namespace_uid = 'cache_user_auth.{}'.format(user_id)
1079 cache_namespace_uid = 'cache_user_auth.{}'.format(user_id)
1080 region = rc_cache.get_or_create_region('cache_perms', cache_namespace_uid)
1080 region = rc_cache.get_or_create_region('cache_perms', cache_namespace_uid)
1081
1081
1082 @region.cache_on_arguments(namespace=cache_namespace_uid,
1082 @region.conditional_cache_on_arguments(namespace=cache_namespace_uid,
1083 should_cache_fn=lambda v: cache_on)
1083 condition=cache_on)
1084 def compute_perm_tree(cache_name,
1084 def compute_perm_tree(cache_name,
1085 user_id, scope, user_is_admin,user_inherit_default_permissions,
1085 user_id, scope, user_is_admin,user_inherit_default_permissions,
1086 explicit, algo, calculate_super_admin):
1086 explicit, algo, calculate_super_admin):
@@ -1277,8 +1277,8 b' class AuthUser(object):'
1277 _set = set()
1277 _set = set()
1278
1278
1279 if inherit_from_default:
1279 if inherit_from_default:
1280 default_ips = UserIpMap.query().filter(
1280 def_user_id = User.get_default_user(cache=True).user_id
1281 UserIpMap.user == User.get_default_user(cache=True))
1281 default_ips = UserIpMap.query().filter(UserIpMap.user_id == def_user_id)
1282 if cache:
1282 if cache:
1283 default_ips = default_ips.options(
1283 default_ips = default_ips.options(
1284 FromCache("sql_cache_short", "get_user_ips_default"))
1284 FromCache("sql_cache_short", "get_user_ips_default"))
@@ -317,9 +317,9 b' class SimpleVCS(object):'
317 cache_namespace_uid = 'cache_user_auth.{}'.format(user_id)
317 cache_namespace_uid = 'cache_user_auth.{}'.format(user_id)
318 region = rc_cache.get_or_create_region('cache_perms', cache_namespace_uid)
318 region = rc_cache.get_or_create_region('cache_perms', cache_namespace_uid)
319
319
320 @region.cache_on_arguments(namespace=cache_namespace_uid,
320 @region.conditional_cache_on_arguments(namespace=cache_namespace_uid,
321 expiration_time=cache_ttl,
321 expiration_time=cache_ttl,
322 should_cache_fn=lambda v: plugin_cache_active)
322 condition=plugin_cache_active)
323 def compute_perm_vcs(
323 def compute_perm_vcs(
324 cache_name, plugin_id, action, user_id, repo_name, ip_addr):
324 cache_name, plugin_id, action, user_id, repo_name, ip_addr):
325
325
@@ -216,7 +216,7 b' class SettingsModel(BaseModel):'
216 def get_all_settings(self, cache=False):
216 def get_all_settings(self, cache=False):
217 region = rc_cache.get_or_create_region('sql_cache_short')
217 region = rc_cache.get_or_create_region('sql_cache_short')
218
218
219 @region.cache_on_arguments(should_cache_fn=lambda v: cache)
219 @region.conditional_cache_on_arguments(condition=cache)
220 def _get_all_settings(name, key):
220 def _get_all_settings(name, key):
221 q = self._get_settings_query()
221 q = self._get_settings_query()
222 if not q:
222 if not q:
@@ -78,7 +78,7 b' class TestCaches(object):'
78
78
79 assert cache_region.backend.list_keys() == []
79 assert cache_region.backend.list_keys() == []
80
80
81 @cache_region.cache_on_arguments(expiration_time=5)
81 @cache_region.conditional_cache_on_arguments(expiration_time=5)
82 def compute(key):
82 def compute(key):
83 return time.time()
83 return time.time()
84
84
@@ -94,7 +94,7 b' class TestCaches(object):'
94 cache_region.delete(key)
94 cache_region.delete(key)
95 assert cache_region.backend.list_keys() == []
95 assert cache_region.backend.list_keys() == []
96
96
97 @cache_region.cache_on_arguments(expiration_time=5)
97 @cache_region.conditional_cache_on_arguments(expiration_time=5)
98 def compute(key):
98 def compute(key):
99 return time.time()
99 return time.time()
100
100
General Comments 0
You need to be logged in to leave comments. Login now