This decorator will memoise a function in the cache. More...
Public Member Functions | |
def | __init__ (self, path) |
Wraps a function in a cache decorator. More... | |
def | generate (self, path, g) |
Special handling for generators. More... | |
def | dump (self, path, payload) |
def | __call__ (self, f) |
Public Attributes | |
path | |
node | |
See if the path is callable: More... | |
This decorator will memoise a function in the cache.
def volatility.cache.CacheDecorator.__init__ | ( | self, | |
path | |||
) |
Wraps a function in a cache decorator.
The results of the function will be cached and memoised. Further calls to the function will retrieve the result from the cache. Cached objects are stored with the specified path as a key.
Args: path: Key for storage into the cache. If this is callable, it will be called with the function's args and is expected to return a string which will be used as a path.
Returns: A decorator.
Example: Suppose the calculate function is decorated:
(lambda self: "tests/pslist/pid{0}/".format(self._config.PID)) def calculate(self): ....
Note the use of the callback to finely tune the cache key depending on external variables.
def volatility.cache.CacheDecorator.generate | ( | self, | |
path, | |||
g | |||
) |
Special handling for generators.
We pass each iteration back immediately, and keep it in a list. Note that if the generator is aborted, the cache is not dumped.
volatility.cache.CacheDecorator.node |
See if the path is callable:
Check if the result can be retrieved