Caching¶
This module provides various caching mechanisms and utilities.
-
class
brownie.caching.
cached_property
(getter, doc=None)[source]¶ Property which caches the result of the given getter.
Parameters: doc – Optional docstring which is used instead of the getters docstring.
-
class
brownie.caching.
CacheBase
[source]¶ Base class for all caches, which is supposed to be used as a mixin.
-
classmethod
decorate
(maxsize=inf)[source]¶ Returns a decorator which can be used to create functions whose results are cached.
In order to clear the cache of the decorated function call .clear() on it.
@CacheBase.decorate(maxsize=1024) # items stored in the cache def foo(a, b): return a + b # imagine a very expensive operation here
-
classmethod
-
class
brownie.caching.
LRUCache
(mapping=(), maxsize=inf)[source]¶ OrderedDict
based cache which removes the least recently used item once maxsize is reached.Note
The order of the dict is changed each time you access the dict.
-
class
brownie.caching.
LFUCache
(mapping=(), maxsize=inf)[source]¶ dict
based cache which removes the least frequently used item once maxsize is reached.
-
brownie.caching.
memoize
(func)¶ A memoization decorator, which uses a simple dictionary of infinite size as cache:
@memoize() def foo(a, b): return a + b
New in version 0.5.