##// 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 beaker.cache.super_short_term.expire = 10
326 beaker.cache.super_short_term.expire = 10
327 beaker.cache.super_short_term.key_length = 256
327 beaker.cache.super_short_term.key_length = 256
328
328
329 beaker.cache.short_term.type = memory
329 # used for caching user permissions
330 beaker.cache.short_term.expire = 60
330 beaker.cache.short_term.type = file
331 beaker.cache.short_term.expire = 0
331 beaker.cache.short_term.key_length = 256
332 beaker.cache.short_term.key_length = 256
332
333
333 beaker.cache.long_term.type = memory
334 beaker.cache.long_term.type = memory
@@ -301,8 +301,9 b' beaker.cache.super_short_term.type = mem'
301 beaker.cache.super_short_term.expire = 10
301 beaker.cache.super_short_term.expire = 10
302 beaker.cache.super_short_term.key_length = 256
302 beaker.cache.super_short_term.key_length = 256
303
303
304 beaker.cache.short_term.type = memory
304 # used for caching user permissions
305 beaker.cache.short_term.expire = 60
305 beaker.cache.short_term.type = file
306 beaker.cache.short_term.expire = 0
306 beaker.cache.short_term.key_length = 256
307 beaker.cache.short_term.key_length = 256
307
308
308 beaker.cache.long_term.type = memory
309 beaker.cache.long_term.type = memory
@@ -48,7 +48,7 b' from rhodecode.model.db import ('
48 User, Repository, Permission, UserToPerm, UserGroupToPerm, UserGroupMember,
48 User, Repository, Permission, UserToPerm, UserGroupToPerm, UserGroupMember,
49 UserIpMap, UserApiKeys, RepoGroup, UserGroup)
49 UserIpMap, UserApiKeys, RepoGroup, UserGroup)
50 from rhodecode.lib import caches
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 from rhodecode.lib.utils import (
52 from rhodecode.lib.utils import (
53 get_repo_slug, get_repo_group_slug, get_user_group_slug)
53 get_repo_slug, get_repo_group_slug, get_user_group_slug)
54 from rhodecode.lib.caching_query import FromCache
54 from rhodecode.lib.caching_query import FromCache
@@ -1070,10 +1070,16 b' class AuthUser(object):'
1070 # inheritance of global permissions like create repo/fork repo etc
1070 # inheritance of global permissions like create repo/fork repo etc
1071 user_inherit_default_permissions = user.inherit_default_permissions
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 compute = caches.conditional_cache(
1080 compute = caches.conditional_cache(
1075 'short_term', 'cache_desc',
1081 'short_term', 'cache_desc',
1076 condition=cache, func=_cached_perms_data)
1082 condition=cache_on, func=_cached_perms_data)
1077 result = compute(user_id, scope, user_is_admin,
1083 result = compute(user_id, scope, user_is_admin,
1078 user_inherit_default_permissions, explicit, algo,
1084 user_inherit_default_permissions, explicit, algo,
1079 calculate_super_admin)
1085 calculate_super_admin)
@@ -298,8 +298,8 b' beaker.cache.super_short_term.type = mem'
298 beaker.cache.super_short_term.expire = 1
298 beaker.cache.super_short_term.expire = 1
299 beaker.cache.super_short_term.key_length = 256
299 beaker.cache.super_short_term.key_length = 256
300
300
301 beaker.cache.short_term.type = memory
301 beaker.cache.short_term.type = file
302 beaker.cache.short_term.expire = 60
302 beaker.cache.short_term.expire = 0
303 beaker.cache.short_term.key_length = 256
303 beaker.cache.short_term.key_length = 256
304
304
305 beaker.cache.long_term.type = memory
305 beaker.cache.long_term.type = memory
General Comments 0
You need to be logged in to leave comments. Login now