s.p.PersistentDict(PersistentDictBase) : class documentation

Part of sasync.pdict View In Hierarchy Source for pdict.py Main doc for sAsync

I am a database-persistent dictionary-like object with memory caching of items and lazy writing.

Getting, setting, or deleting my items returns Deferred objects of the Twisted asynchronous framework that fire when the underlying database accesses are completed. Returning a deferred value avoids forcing the client code to block while the real value is being read from the database.

Instance Variable data The in-memory dictionary that each instance of me uses to cache values for a given ID.
Method __getitem__ Returns a Deferred to the value of item name or the value itself if in preload mode.
Method __setitem__ Sets item name to value, saving it to the database if there isn't already an in-memory dictionary item with that exact value.
Method __delitem__ Deletes item name, removing its entry from both the in-memory dictionary and the database
Method __contains__ Indicates if I contain item key.
Method keys Returns an immediate or deferred list of the names of all my items in the database.
Method has_key Returns an immediate or deferred Boolean indicating whether the key is present.
Method clear Clears the in-memory dictionary of all items and deletes all their database entries.
Method __iter__ Only for preload mode: Iterate over all my keys.
Method iteritems Only for preload mode: Iterate over all my items.
Method iterkeys Only for preload mode: Iterate over all my keys.
Method itervalues Only for preload mode: Iterate over all my values.
Method __len__ Returns an immediate or deferred integer with my length, i.e., the number of keys.
Method items Returns an immediate or deferred sequence of (name, value) tuples representing all my items.
Method values Returns an immediate or deferred sequence of all my values.
Method get No summary
Method setdefault Sets my item specified by key to value if it doesn't exist already. Returns an immediate or deferred reference to the item's value after its new value (if any) is set.
Method copy Returns an immediate or deferred copy of me that is a conventional (non-persisted) dictionary.

Inherited from PersistentDictBase:

Instance Variable isPreloadMode Boolean flag that indicates if I am operating in preload mode.
Method __init__ Instantiates me with an item store keyed to the supplied hashable ID.
Method waitUntilRunning Undocumented
Method preload This method preloads all my items from the database (which may take a while), returning a Deferred that fires when everything's ready and I've completed the transition into preload mode.
Method shutdown Shuts down my database AccessBroker and its synchronous task queue.
Method loadAll Loads all items from the database, setting my in-memory dict and key cache accordingly.
Method deferToWrites
data =
The in-memory dictionary that each instance of me uses to cache values for a given ID.
def __getitem__(self, name):

Returns a Deferred to the value of item name or the value itself if in preload mode.

The value is only loaded from the database if it isn't already in the in-memory dictionary.

def __setitem__(self, name, value):

Sets item name to value, saving it to the database if there isn't already an in-memory dictionary item with that exact value.

def __delitem__(self, name):

Deletes item name, removing its entry from both the in-memory dictionary and the database

def __contains__(self, key):

Indicates if I contain item key.

In preload mode, returns True if the item is present in my in-memory dictionary and False if not.

In normal mode, returns an immediate Deferred firing with True without a transaction if the item is already present in my in-memory dictionary. If it isn't, tries to load the item (it will probably be requested soon anyhow) and returns a Deferred that will ultimately fire with True unless the load resulted in a Missing object. In that case, deletes the loaded Missing object from my in-memory dictionary and fires the deferred with False.

Using the <key> in <dict> Python construct doesn't seem to work in normal mode. Use has_key instead.

def keys(self):

Returns an immediate or deferred list of the names of all my items in the database.

def has_key(self, key):

Returns an immediate or deferred Boolean indicating whether the key is present.

def clear(self):

Clears the in-memory dictionary of all items and deletes all their database entries.

def __iter__(self):

Only for preload mode: Iterate over all my keys.

def iteritems(self):

Only for preload mode: Iterate over all my items.

def iterkeys(self):

Only for preload mode: Iterate over all my keys.

def itervalues(self):

Only for preload mode: Iterate over all my values.

def __len__(self):

Returns an immediate or deferred integer with my length, i.e., the number of keys.

def items(self):

Returns an immediate or deferred sequence of (name, value) tuples representing all my items.

def values(self):

Returns an immediate or deferred sequence of all my values.

def get(self, *args):

Returns an immediate or deferred value of the value for the key specified as the first argument, or a default value if specified as an optional second argument. If the item is not present and no default value is supplied, raises the appropriate exception.

def setdefault(self, key, value):

Sets my item specified by key to value if it doesn't exist already. Returns an immediate or deferred reference to the item's value after its new value (if any) is set.

def copy(self):

Returns an immediate or deferred copy of me that is a conventional (non-persisted) dictionary.

API Documentation for sAsync, generated by pydoctor at 2016-11-16 14:52:15.