##// END OF EJS Templates
permissions: enable caching by controlling short_term cache settings.
marcink -
r2796:3deed041 default
parent child Browse files
Show More
@@ -326,8 +326,9 b' beaker.cache.super_short_term.type = mem'
326 326 beaker.cache.super_short_term.expire = 10
327 327 beaker.cache.super_short_term.key_length = 256
328 328
329 beaker.cache.short_term.type = memory
330 beaker.cache.short_term.expire = 60
329 # used for caching user permissions
330 beaker.cache.short_term.type = file
331 beaker.cache.short_term.expire = 0
331 332 beaker.cache.short_term.key_length = 256
332 333
333 334 beaker.cache.long_term.type = memory
@@ -301,8 +301,9 b' beaker.cache.super_short_term.type = mem'
301 301 beaker.cache.super_short_term.expire = 10
302 302 beaker.cache.super_short_term.key_length = 256
303 303
304 beaker.cache.short_term.type = memory
305 beaker.cache.short_term.expire = 60
304 # used for caching user permissions
305 beaker.cache.short_term.type = file
306 beaker.cache.short_term.expire = 0
306 307 beaker.cache.short_term.key_length = 256
307 308
308 309 beaker.cache.long_term.type = memory
@@ -48,7 +48,7 b' from rhodecode.model.db import ('
48 48 User, Repository, Permission, UserToPerm, UserGroupToPerm, UserGroupMember,
49 49 UserIpMap, UserApiKeys, RepoGroup, UserGroup)
50 50 from rhodecode.lib import caches
51 from rhodecode.lib.utils2 import safe_unicode, aslist, safe_str, md5
51 from rhodecode.lib.utils2 import safe_unicode, aslist, safe_str, md5, safe_int
52 52 from rhodecode.lib.utils import (
53 53 get_repo_slug, get_repo_group_slug, get_user_group_slug)
54 54 from rhodecode.lib.caching_query import FromCache
@@ -1070,10 +1070,16 b' class AuthUser(object):'
1070 1070 # inheritance of global permissions like create repo/fork repo etc
1071 1071 user_inherit_default_permissions = user.inherit_default_permissions
1072 1072
1073 log.debug('Computing PERMISSION tree for scope %s' % (scope, ))
1073 cache_seconds = safe_int(
1074 rhodecode.CONFIG.get('beaker.cache.short_term.expire'))
1075 cache_on = cache or cache_seconds > 0
1076 log.debug(
1077 'Computing PERMISSION tree for scope `%s` with caching: %s' % (
1078 scope, cache_on))
1079
1074 1080 compute = caches.conditional_cache(
1075 1081 'short_term', 'cache_desc',
1076 condition=cache, func=_cached_perms_data)
1082 condition=cache_on, func=_cached_perms_data)
1077 1083 result = compute(user_id, scope, user_is_admin,
1078 1084 user_inherit_default_permissions, explicit, algo,
1079 1085 calculate_super_admin)
@@ -298,8 +298,8 b' beaker.cache.super_short_term.type = mem'
298 298 beaker.cache.super_short_term.expire = 1
299 299 beaker.cache.super_short_term.key_length = 256
300 300
301 beaker.cache.short_term.type = memory
302 beaker.cache.short_term.expire = 60
301 beaker.cache.short_term.type = file
302 beaker.cache.short_term.expire = 0
303 303 beaker.cache.short_term.key_length = 256
304 304
305 305 beaker.cache.long_term.type = memory
General Comments 0
You need to be logged in to leave comments. Login now