Mercurial > libervia-backend
comparison sat/memory/persistent.py @ 3253:1af840e84af7
core (memory/persistent): fixed "items", added "all" + "adel" to LazyPersistentBinaryDict:
- `items` was returning the dict with all values, it now returns a Deferred with actual dict items()
- `all` new method does return the dict with all values (in a Deferred)
- `adel` has been added to LazyPersistentBinaryDict
author | Goffi <goffi@goffi.org> |
---|---|
date | Tue, 14 Apr 2020 20:36:24 +0200 |
parents | 78fea49735c5 |
children | be6d91572633 |
comparison
equal
deleted
inserted
replaced
3252:54934ee3f69c | 3253:1af840e84af7 |
---|---|
64 | 64 |
65 def iteritems(self): | 65 def iteritems(self): |
66 return iter(self._cache.items()) | 66 return iter(self._cache.items()) |
67 | 67 |
68 def items(self): | 68 def items(self): |
69 return list(self._cache.items()) | 69 return self._cache.items() |
70 | 70 |
71 def __repr__(self): | 71 def __repr__(self): |
72 return self._cache.__repr__() | 72 return self._cache.__repr__() |
73 | 73 |
74 def __str__(self): | 74 def __str__(self): |
176 | 176 |
177 def iteritems(self): | 177 def iteritems(self): |
178 raise NotImplementedError | 178 raise NotImplementedError |
179 | 179 |
180 def items(self): | 180 def items(self): |
181 d = self.storage.getPrivates(self.namespace, binary=self.binary, profile=self.profile) | |
182 d.addCallback(lambda data_dict: data_dict.items()) | |
183 return d | |
184 | |
185 def all(self): | |
181 return self.storage.getPrivates(self.namespace, binary=self.binary, profile=self.profile) | 186 return self.storage.getPrivates(self.namespace, binary=self.binary, profile=self.profile) |
182 | 187 |
183 def __repr__(self): | 188 def __repr__(self): |
184 raise NotImplementedError | 189 raise NotImplementedError |
185 | 190 |
255 # FIXME: redundant with force, force must be removed | 260 # FIXME: redundant with force, force must be removed |
256 # XXX: similar as PersistentDict.aset, but doesn't use cache | 261 # XXX: similar as PersistentDict.aset, but doesn't use cache |
257 return self.storage.setPrivateValue(self.namespace, key, value, | 262 return self.storage.setPrivateValue(self.namespace, key, value, |
258 self.binary, self.profile) | 263 self.binary, self.profile) |
259 | 264 |
265 def adel(self, key): | |
266 """Async del, return a Deferred fired when value is actually deleted""" | |
267 # XXX: similar as PersistentDict.adel, but doesn't use cache | |
268 return self.storage.delPrivateValue( | |
269 self.namespace, key, self.binary, self.profile) | |
270 | |
260 def setdefault(self, key, default): | 271 def setdefault(self, key, default): |
261 raise NotImplementedError | 272 raise NotImplementedError |
262 | 273 |
263 def force(self, name, value): | 274 def force(self, name, value): |
264 """Force saving of an attribute to storage | 275 """Force saving of an attribute to storage |