chore(caches): cleanup cache lib and added cleanup backend
This commit is contained in:
parent
efb6d1e422
commit
9a46cbc018
2 changed files with 14 additions and 7 deletions
|
|
@ -38,9 +38,9 @@ from dogpile.cache.backends import redis as redis_backend
|
|||
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(PickleSerializer, file_backend.DBMBackend):
|
|||
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(MsgPackSerializer, BaseRedisBackend):
|
|||
|
||||
|
||||
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"""
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue