From 973beb4220045eec1945e60668a386b68c1f93e2 Mon Sep 17 00:00:00 2001 From: Goffi Date: Fri, 27 Mar 2020 09:53:00 +0100 Subject: [PATCH] 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. --- sat/memory/persistent.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/sat/memory/persistent.py b/sat/memory/persistent.py index 2a6e4577..67049092 100644 --- a/sat/memory/persistent.py +++ b/sat/memory/persistent.py @@ -27,7 +27,7 @@ class MemoryNotInitializedError(Exception): 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 @@ class LazyPersistentBinaryDict(PersistentBinaryDict): 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