# HG changeset patch # User RhodeCode Admin # Date 2023-07-18 09:27:03 # Node ID 367165a5ae8617795972fda1e4b936f6cf2e1909 # Parent f96985cd1388d43b13431a22bea03005a62a7c8e caches: synced with CE changes diff --git a/vcsserver/lib/rc_cache/archive_cache.py b/vcsserver/lib/rc_cache/archive_cache.py --- a/vcsserver/lib/rc_cache/archive_cache.py +++ b/vcsserver/lib/rc_cache/archive_cache.py @@ -18,13 +18,28 @@ import logging import os import diskcache +from diskcache import RLock log = logging.getLogger(__name__) cache_meta = None +class ReentrantLock(RLock): + def __enter__(self): + reentrant_lock_key = self._key + + log.debug('Acquire ReentrantLock(key=%s) for archive cache generation...', reentrant_lock_key) + #self.acquire() + log.debug('Lock for key=%s acquired', reentrant_lock_key) + + def __exit__(self, *exc_info): + #self.release() + pass + + def get_archival_config(config): + final_config = { 'archive_cache.eviction_policy': 'least-frequently-used' } diff --git a/vcsserver/lib/rc_cache/utils.py b/vcsserver/lib/rc_cache/utils.py --- a/vcsserver/lib/rc_cache/utils.py +++ b/vcsserver/lib/rc_cache/utils.py @@ -24,10 +24,12 @@ import time import decorator from dogpile.cache import CacheRegion -from vcsserver.lib.rc_cache import region_meta + +from vcsserver.utils import sha1 from vcsserver.str_utils import safe_bytes from vcsserver.type_utils import str2bool -from vcsserver.utils import sha1 + +from . import region_meta log = logging.getLogger(__name__) @@ -164,8 +166,9 @@ def backend_key_generator(backend): return wrapper -def get_or_create_region(region_name, region_namespace: str = None): - from vcsserver.lib.rc_cache.backends import FileNamespaceBackend +def get_or_create_region(region_name, region_namespace: str = None, use_async_runner=False): + from .backends import FileNamespaceBackend + from . import async_creation_runner region_obj = region_meta.dogpile_cache_regions.get(region_name) if not region_obj: @@ -215,6 +218,8 @@ def get_or_create_region(region_name, re region_obj = region_meta.dogpile_cache_regions[region_namespace] = new_region region_obj._default_namespace = region_namespace + if use_async_runner: + region_obj.async_creation_runner = async_creation_runner return region_obj