iotcs.persistence module

class iotcs.persistence.PersistenceStore

Bases: abc.ABC

PersistenceStore.

class Transaction

Bases: abc.ABC

Interface for modifying values in a PersistenceStore.

The PersistenceStore itself is not updated until commit() is called.

clear()

Mark all values to be removed from the PersistenceStore object.

When commit() is called, values are removed before put methods are processed.

:return this Transaction object

commit()

Commit this transaction.

This method persists the values to the backing store and replaces the values in the PersistenceStore} object. :return: True if the values were persisted

put(key, value)

Set a value for the key.

key is written back to the :class:.PersistenceStore` object when commit() is called. :param key: a key to be used to retrieve the value :param value: the value :return: this Transaction object

remove(key)

Mark all values to be removed from the PersistenceStore object.

When commit() is called, values are removed before put methods are processed.

Parameters:key – a key whose value is to be removed
Returns:this Transaction object
contains(key)

Return True if this PersistenceStore contains the given key.

Parameters:key – the key to search for
Returns:True if this PersistenceStore contains the given key
get(key, defaultValue=None)

Return a value for the given key. :param key: the key to search for :param defaultValue: the value to use if this PersistenceStore does

not contain the key
Returns:the value for the key
getAll()

Return a map of all key/value pairs in this PersistenceStore

getLock()

Return the lock for this PersistenceStore.

getName()

Return the name used by the PersistenceManager to reference this PersistenceStore. :return The PersistenceStore} name.

openTransaction()

Open a Transaction object for modifying the values of this PersistenceStore. :return: a Transaction object

class iotcs.persistence.PersistenceStoreManager

Bases: object

PersistenceStoreManager.

class InMemoryPersistenceStore(name)

Bases: iotcs.persistence.PersistenceStore

An in memory PersistenceStore.

Create an instance of InMemoryPersistenceStore.

class Transaction(persistencestore)

Bases: iotcs.persistence.Transaction

A Transaction processing class.

Creat a Transaction instance.

Parameters:persistencestore – open a transaction on this PersistenceStore
Raise:Argument if persistencestore is None
clear()

Clear all entries in the transaction. :return: this instance

commit()

Commit the transaction. :return: True

map
maplock
peristencestore
put(key, value)

Add key and value to the current transaction. :return: this instance

remove(key)

Remove key from the transaction.

contains(key)

Return True if key is in this PersistenceStore.

get(key, defaultValue=None)

Return the value for key or defaultValue from this PersistenceStore.

getAll()

Return a copy of the map of persisted objects.

getLock()

Return the lock for this PersistenceStore.

getName()

Return the name of this PersistenceStore.

map
maplock
name
openTransaction()

Open a transaction in this PersistenceStore.

classmethod getPersistenceStore(name)

Return the PersistenceStore with name.