changeset 3234:78fea49735c5

core (memory/persistent): added `aset` method in LazyPersistentBinaryDict: this method does the same as `force` but is there to be consistent with PersistentDict. `force` should be removed in the future.
author Goffi <goffi@goffi.org>
date Fri, 27 Mar 2020 09:53:00 +0100
parents 8770397f8f82
children c161ff21ca7c
files sat/memory/persistent.py
diffstat 1 files changed, 8 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/sat/memory/persistent.py	Fri Mar 27 09:50:42 2020 +0100
+++ b/sat/memory/persistent.py	Fri Mar 27 09:53:00 2020 +0100
@@ -27,7 +27,7 @@
     pass
 
 
-class PersistentDict(object):
+class PersistentDict:
     r"""A dictionary which save persistently each value assigned
 
     /!\ be careful, each assignment means a database write
@@ -250,6 +250,13 @@
         d.addErrback(self._defaultOrException, default=default)
         return d
 
+    def aset(self, key, value):
+        """Async set, return a Deferred fired when value is actually stored"""
+        # FIXME: redundant with force, force must be removed
+        # XXX: similar as PersistentDict.aset, but doesn't use cache
+        return self.storage.setPrivateValue(self.namespace, key, value,
+                                            self.binary, self.profile)
+
     def setdefault(self, key, default):
         raise NotImplementedError