Package memtools :: Module protocols :: Class Memory
[hide private]

Class Memory

source code


Memory objects are key-value gateways to a database or any other kind of memory storage. They behave the same way dictionaries do, which makes it easier to mock them.

Required methods are __getitem__, __setitem__ and __delitem__. get(), set() are mapped to __getitem__ and __setitem__.

A convenience method __call__ is defined to use objects of this class as decorators. Doing so will apply the memorize pattern to the function. You can find more information in the corresponding docstring in __call__.

Instance Methods [hide private]
 
__call__(self, f)
This is a convenience function that provides the Memory Pattern as a decorator and wraps it in a way transparent to the end user (i.e.: they will not know whether the function has been decorated or not). This is acomplished by using the "wrap" decorator in functools.
source code
 
__delitem__(self, key) source code
 
__getitem__(self, key) source code
 
__setitem__(self, key, value) source code
 
get(self, key) source code
 
set(self, key, value) source code

Inherited from object: __delattr__, __getattribute__, __hash__, __init__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __str__

Properties [hide private]

Inherited from object: __class__