Skip to content

Commit

Permalink
Documentation for Info listener class
Browse files Browse the repository at this point in the history
  • Loading branch information
kitmonisit committed Apr 16, 2021
1 parent dcf3416 commit db7e220
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
14 changes: 8 additions & 6 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -86,18 +86,20 @@ You can add a default, pickle-based, persistent cache to your function - meaning
Did the result come from the cache?
-----------------------------------

You can find out of the function returned a value from the cache or not, by
calling the ``is_from_cache()`` function:
You can find out of the function returned a value from the cache or not, passing
an ``Info`` object to the decorated function, then inspecting its
``is_from_cache`` attribute:

.. code-block:: python
>>> foo(1, 2)
>>> call_info = cachier.Info()
>>> foo(1, 2, cachier_info=call_info)
{'arg1': 1, 'arg2': 2}
>>> foo.is_from_cache()
>>> call_info.is_from_cache
False
>>> foo(1, 2)
>>> foo(1, 2, cachier_info=call_info)
{'arg1': 1, 'arg2': 2}
>>> foo.is_from_cache()
>>> call_info.is_from_cache
True
Expand Down
2 changes: 0 additions & 2 deletions tests/test_pickle_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,6 @@ def test_cachier_info():
assert int4 != int3
assert int4 == int1
_random_num_with_arg.clear_cache()
pass



@cachier()
Expand Down

0 comments on commit db7e220

Please sign in to comment.