bluesky.utils.PersistentDict¶
-
class
bluesky.utils.PersistentDict(directory)[source]¶ A MutableMapping which syncs it contents to disk.
The contents are stored as msgpack-serialized files, with one file per item in the mapping.
Note that when an item is mutated it is not immediately synced:
>>> d['sample'] = {"color": "red"} # immediately synced >>> d['sample']['shape'] = 'bar' # not immediately synced
but that the full contents are synced to disk when the PersistentDict instance is garbage collected.
Methods
__init__(directory)Initialize self.
clear()close()Release any system resources held by this object.
flush()Force a write of the current state to disk
get(k[,d])items()keys()pop(k[,d])If key is not found, d is returned if given, otherwise KeyError is raised.
popitem()as a 2-tuple; but raise KeyError if D is empty.
reload()Force a reload from disk, overwriting current cache
setdefault(k[,d])update([E, ]**F)If E present and has a .keys() method, does: for k in E: D[k] = E[k] If E present and lacks .keys() method, does: for (k, v) in E: D[k] = v In either case, this is followed by: for k, v in F.items(): D[k] = v
values()Attributes