diff options
Diffstat (limited to 'docs/narr.rst')
-rw-r--r-- | docs/narr.rst | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/docs/narr.rst b/docs/narr.rst index 6c46325..f819698 100644 --- a/docs/narr.rst +++ b/docs/narr.rst @@ -63,3 +63,33 @@ decorated function must be hashable. It does not support keyword arguments: Each function decorated with the lru_cache decorator uses its own cache related to that function. + +Cleaning cache of decorated function +------------------------------------ + +:mod:`repoze.lru` provides a :class:`~repoze.lru.CacheMaker`, which generates +decorators. This way, you can later clear your cache if needed. + +.. doctest:: + + >>> from repoze.lru import CacheMaker + >>> cache_maker=CacheMaker() + >>> @cache_maker.lrucache(maxsize=300, name="adder") + ... def yet_another_exepensive_function(*arg):#* + ... pass + + >>> @cache_maker.expiring_lrucache(maxsize=300,timeout=30) + ... def another_exepensive_function(*arg):#* + ... pass + +This way, when you need it you can choose to either clear all cache: + +.. doctest:: + + >>> cache_maker.clear() + +or clear a specific cache + +.. doctest:: + + >>> cache_maker.clear("adder") |