# HG changeset patch # User RhodeCode Admin # Date 2024-08-07 11:40:30 # Node ID f4c81595635c29390836fbf37cd369ece06106e3 # Parent cab50adfd66bbe2ca006caa7298fc7be4ab1e48c chore(caches): cleanup cache lib and added cleanup backend diff --git a/rhodecode/lib/rc_cache/backends.py b/rhodecode/lib/rc_cache/backends.py --- a/rhodecode/lib/rc_cache/backends.py +++ b/rhodecode/lib/rc_cache/backends.py @@ -38,9 +38,9 @@ from dogpile.cache.backends import redis from dogpile.cache.backends.file import FileLock from dogpile.cache.util import memoized_property -from rhodecode.lib.memory_lru_dict import LRUDict, LRUDictDebug -from rhodecode.lib.str_utils import safe_bytes, safe_str -from rhodecode.lib.type_utils import str2bool +from ...lib.memory_lru_dict import LRUDict, LRUDictDebug +from ...lib.str_utils import safe_bytes, safe_str +from ...lib.type_utils import str2bool _default_max_size = 1024 @@ -198,6 +198,13 @@ class FileNamespaceBackend(PickleSeriali def get_store(self): return self.filename + def cleanup_store(self): + for ext in ("db", "dat", "pag", "dir"): + final_filename = self.filename + os.extsep + ext + if os.path.exists(final_filename): + os.remove(final_filename) + log.warning('Removed dbm file %s', final_filename) + class BaseRedisBackend(redis_backend.RedisBackend): key_prefix = '' @@ -289,7 +296,7 @@ class RedisMsgPackBackend(MsgPackSeriali def get_mutex_lock(client, lock_key, lock_timeout, auto_renewal=False): - from rhodecode.lib._vendor import redis_lock + from ...lib._vendor import redis_lock class _RedisLockWrapper: """LockWrapper for redis_lock""" diff --git a/rhodecode/lib/rc_cache/utils.py b/rhodecode/lib/rc_cache/utils.py --- a/rhodecode/lib/rc_cache/utils.py +++ b/rhodecode/lib/rc_cache/utils.py @@ -26,9 +26,9 @@ import decorator from dogpile.cache import CacheRegion import rhodecode -from rhodecode.lib.hash_utils import sha1 -from rhodecode.lib.str_utils import safe_bytes -from rhodecode.lib.type_utils import str2bool # noqa :required by imports from .utils +from ...lib.hash_utils import sha1 +from ...lib.str_utils import safe_bytes +from ...lib.type_utils import str2bool # noqa :required by imports from .utils from . import region_meta