##// END OF EJS Templates
logging: use just func names for logs instead of objects with memory address (doesn't give any valueable info)
logging: use just func names for logs instead of objects with memory address (doesn't give any valueable info)

File last commit:

r735:0116033a default
r778:eaf5cd79 default
Show More
__init__.py
72 lines | 2.6 KiB | text/x-python | PythonLexer
caches: replaced beaker with dogpile cache.
r483 # RhodeCode VCSServer provides access to different vcs backends via network.
docs: updated copyrights to 2019
r620 # Copyright (C) 2014-2019 RhodeCode GmbH
caches: replaced beaker with dogpile cache.
r483 #
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# 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 General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
import logging
from dogpile.cache import register_backend
register_backend(
"dogpile.cache.rc.memory_lru", "vcsserver.lib.rc_cache.backends",
"LRUMemoryBackend")
caches: added redis backend as an option
r733 register_backend(
"dogpile.cache.rc.file_namespace", "vcsserver.lib.rc_cache.backends",
"FileNamespaceBackend")
register_backend(
"dogpile.cache.rc.redis", "vcsserver.lib.rc_cache.backends",
"RedisPickleBackend")
caches: add pickle/msgpack serializers for redis.
r735 register_backend(
"dogpile.cache.rc.redis_msgpack", "vcsserver.lib.rc_cache.backends",
"RedisMsgPackBackend")
caches: added redis backend as an option
r733
caches: replaced beaker with dogpile cache.
r483 log = logging.getLogger(__name__)
from . import region_meta
caches: don't use key_manglers instead prefix keys based on backend.
r734 from .utils import (get_default_cache_settings, backend_key_generator, make_region)
caches: replaced beaker with dogpile cache.
r483
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]
avail_regions.add(namespace_name)
log.debug('dogpile: found following cache regions: %s', avail_regions)
# register them into namespace
for region_name in avail_regions:
new_region = make_region(
name=region_name,
caches: don't use key_manglers instead prefix keys based on backend.
r734 function_key_generator=None
caches: replaced beaker with dogpile cache.
r483 )
new_region.configure_from_config(settings, 'rc_cache.{}.'.format(region_name))
caches: don't use key_manglers instead prefix keys based on backend.
r734 new_region.function_key_generator = backend_key_generator(new_region.actual_backend)
log.debug('dogpile: registering a new region %s[%s]', region_name, new_region.__dict__)
caches: replaced beaker with dogpile cache.
r483 region_meta.dogpile_cache_regions[region_name] = new_region
def includeme(config):
configure_dogpile_cache(config.registry.settings)