##// END OF EJS Templates
caches: use safest possible pickle for cache backends....
marcink -
r2909:dfc57a11 default
parent child Browse files
Show More
@@ -62,11 +62,23 b' class LRUMemoryBackend(memory_backend.Me'
62
62
63
63
64 class Serializer(object):
64 class Serializer(object):
65 def _dumps(self, value):
65 def _dumps(self, value, safe=False):
66 return compat.pickle.dumps(value)
66 try:
67 return compat.pickle.dumps(value)
68 except Exception:
69 if safe:
70 return NO_VALUE
71 else:
72 raise
67
73
68 def _loads(self, value):
74 def _loads(self, value, safe=True):
69 return compat.pickle.loads(value)
75 try:
76 return compat.pickle.loads(value)
77 except Exception:
78 if safe:
79 return NO_VALUE
80 else:
81 raise
70
82
71
83
72 class CustomLockFactory(FileLock):
84 class CustomLockFactory(FileLock):
@@ -159,6 +171,12 b' class RedisPickleBackend(Serializer, red'
159 def get_store(self):
171 def get_store(self):
160 return self.client.connection_pool
172 return self.client.connection_pool
161
173
174 def get(self, key):
175 value = self.client.get(key)
176 if value is None:
177 return NO_VALUE
178 return self._loads(value)
179
162 def set(self, key, value):
180 def set(self, key, value):
163 if self.redis_expiration_time:
181 if self.redis_expiration_time:
164 self.client.setex(key, self.redis_expiration_time,
182 self.client.setex(key, self.redis_expiration_time,
General Comments 0
You need to be logged in to leave comments. Login now