##// END OF EJS Templates
caches: dbm backend needs to use bytes to list keys
super-admin -
r5022:b2c2c0f3 default
parent child Browse files
Show More
@@ -41,7 +41,7 b' from dogpile.cache.api import Serializer'
41 41 from pyramid.settings import asbool
42 42
43 43 from rhodecode.lib.memory_lru_dict import LRUDict, LRUDictDebug
44 from rhodecode.lib.str_utils import safe_str
44 from rhodecode.lib.str_utils import safe_str, safe_bytes
45 45
46 46
47 47 _default_max_size = 1024
@@ -146,20 +146,20 b' class FileNamespaceBackend(PickleSeriali'
146 146 def __repr__(self):
147 147 return '{} `{}`'.format(self.__class__, self.filename)
148 148
149 def list_keys(self, prefix=''):
150 prefix = '{}:{}'.format(self.key_prefix, prefix)
149 def list_keys(self, prefix: bytes = b''):
150 prefix = b'%b:%b' % (safe_bytes(self.key_prefix), safe_bytes(prefix))
151 151
152 def cond(v):
152 def cond(dbm_key: bytes):
153 153 if not prefix:
154 154 return True
155 155
156 if v.startswith(prefix):
156 if dbm_key.startswith(prefix):
157 157 return True
158 158 return False
159 159
160 160 with self._dbm_file(True) as dbm:
161 161 try:
162 return list(filter(cond, list(dbm.keys())))
162 return list(filter(cond, dbm.keys()))
163 163 except Exception:
164 164 log.error('Failed to fetch DBM keys from DB: %s', self.get_store())
165 165 raise
General Comments 0
You need to be logged in to leave comments. Login now