##// END OF EJS Templates
python3: fixed raw-input
python3: fixed raw-input

File last commit:

r4594:46592d9a stable
r4962:562a7580 default
Show More
__init__.py
87 lines | 3.0 KiB | text/x-python | PythonLexer
caches: rewrite of auth/permission caches to dogpile.
r2845 # -*- coding: utf-8 -*-
code: update copyrights to 2020
r4306 # Copyright (C) 2015-2020 RhodeCode GmbH
caches: rewrite of auth/permission caches to dogpile.
r2845 #
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License, version 3
# (only), as published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# This program is dual-licensed. If you wish to learn more about the
# RhodeCode Enterprise Edition, including its added features, Support services,
# and proprietary license terms, please see https://rhodecode.com/licenses/
caches: added logging for dogpile configuration.
r2885 import logging
caches: rewrite of auth/permission caches to dogpile.
r2845 from dogpile.cache import register_backend
register_backend(
"dogpile.cache.rc.memory_lru", "rhodecode.lib.rc_cache.backends",
"LRUMemoryBackend")
register_backend(
"dogpile.cache.rc.file_namespace", "rhodecode.lib.rc_cache.backends",
"FileNamespaceBackend")
register_backend(
"dogpile.cache.rc.redis", "rhodecode.lib.rc_cache.backends",
"RedisPickleBackend")
caches: synced cache logic with vcsserver.
r3851 register_backend(
"dogpile.cache.rc.redis_msgpack", "rhodecode.lib.rc_cache.backends",
"RedisMsgPackBackend")
caches: rewrite of auth/permission caches to dogpile.
r2845
caches: added logging for dogpile configuration.
r2885 log = logging.getLogger(__name__)
caches: rewrite of auth/permission caches to dogpile.
r2845 from . import region_meta
caches: don't use beaker for file caches anymore
r2846 from .utils import (
caches: synced cache logic with vcsserver.
r3851 get_default_cache_settings, backend_key_generator, get_or_create_region,
caches: new cache context managers....
r2932 clear_cache_namespace, make_region, InvalidationContext,
FreshRegionCache, ActiveRegionCache)
caches: rewrite of auth/permission caches to dogpile.
r2845
files: use a common function to handle url-by-refs, and fix landing refs for SVN....
r4373 FILE_TREE_CACHE_VER = 'v4'
license: add helpers to allow users hide license warnings.
r4453 LICENSE_CACHE_VER = 'v2'
cache: bump file-tree caches to next iteration
r4036
caches: rewrite of auth/permission caches to dogpile.
r2845 def configure_dogpile_cache(settings):
cache_dir = settings.get('cache_dir')
if cache_dir:
region_meta.dogpile_config_defaults['cache_dir'] = cache_dir
rc_cache_data = get_default_cache_settings(settings, prefixes=['rc_cache.'])
# inspect available namespaces
avail_regions = set()
for key in rc_cache_data.keys():
namespace_name = key.split('.', 1)[0]
core: speed up cache loading
r4594 if namespace_name in avail_regions:
continue
caches: rewrite of auth/permission caches to dogpile.
r2845
core: speed up cache loading
r4594 avail_regions.add(namespace_name)
log.debug('dogpile: found following cache regions: %s', namespace_name)
caches: rewrite of auth/permission caches to dogpile.
r2845 new_region = make_region(
core: speed up cache loading
r4594 name=namespace_name,
caches: synced cache logic with vcsserver.
r3851 function_key_generator=None
caches: rewrite of auth/permission caches to dogpile.
r2845 )
core: speed up cache loading
r4594 new_region.configure_from_config(settings, 'rc_cache.{}.'.format(namespace_name))
caches: synced cache logic with vcsserver.
r3851 new_region.function_key_generator = backend_key_generator(new_region.actual_backend)
app: improve logging, and remove DB calls on app startup.
r4548 if log.isEnabledFor(logging.DEBUG):
region_args = dict(backend=new_region.actual_backend.__class__,
region_invalidator=new_region.region_invalidator.__class__)
core: speed up cache loading
r4594 log.debug('dogpile: registering a new region `%s` %s', namespace_name, region_args)
app: improve logging, and remove DB calls on app startup.
r4548
core: speed up cache loading
r4594 region_meta.dogpile_cache_regions[namespace_name] = new_region
caches: rewrite of auth/permission caches to dogpile.
r2845
def includeme(config):
configure_dogpile_cache(config.registry.settings)