Skip to content

Commit

Permalink
readme: regenerate & fix template after nbconvert update
Browse files Browse the repository at this point in the history
  • Loading branch information
karlicoss committed Apr 11, 2022
1 parent 1702b5b commit 6fdd070
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
30 changes: 15 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,10 @@ Cachew gives the best of two worlds and makes it both **easy and efficient**. Th


# How it works
Basically, your data objects get [flattened out](src/cachew/__init__.py#L452)
and python types are mapped [onto sqlite types and back](src/cachew/__init__.py#L522).
Basically, your data objects get [flattened out](src/cachew/__init__.py#L438)
and python types are mapped [onto sqlite types and back](src/cachew/__init__.py#L510).

When the function is called, cachew [computes the hash of your function's arguments ](src/cachew/__init__.py:#L841)
When the function is called, cachew [computes the hash of your function's arguments ](src/cachew/__init__.py:#L837)
and compares it against the previously stored hash value.

- If they match, it would deserialize and yield whatever is stored in the cache database
Expand All @@ -135,18 +135,18 @@ and compares it against the previously stored hash value.



* automatic schema inference: [1](src/cachew/tests/test_cachew.py#L341), [2](src/cachew/tests/test_cachew.py#L355)
* automatic schema inference: [1](src/cachew/tests/test_cachew.py#L343), [2](src/cachew/tests/test_cachew.py#L357)
* supported types:

* primitive: `str`, `int`, `float`, `bool`, `datetime`, `date`, `dict`, `list`, `Exception`

See [tests.test_types](src/cachew/tests/test_cachew.py#L621), [tests.test_primitive](src/cachew/tests/test_cachew.py#L668), [tests.test_dates](src/cachew/tests/test_cachew.py#L581)
* [Optional](src/cachew/tests/test_cachew.py#L480) types
* [Union](src/cachew/tests/test_cachew.py#L738) types
* [nested datatypes](src/cachew/tests/test_cachew.py#L397)
* [Exceptions](src/cachew/tests/test_cachew.py#L995)
See [tests.test_types](src/cachew/tests/test_cachew.py#L623), [tests.test_primitive](src/cachew/tests/test_cachew.py#L670), [tests.test_dates](src/cachew/tests/test_cachew.py#L583)
* [Optional](src/cachew/tests/test_cachew.py#L482) types
* [Union](src/cachew/tests/test_cachew.py#L740) types
* [nested datatypes](src/cachew/tests/test_cachew.py#L399)
* [Exceptions](src/cachew/tests/test_cachew.py#L997)

* detects [datatype schema changes](src/cachew/tests/test_cachew.py#L427) and discards old data automatically
* detects [datatype schema changes](src/cachew/tests/test_cachew.py#L429) and discards old data automatically


# Performance
Expand All @@ -157,25 +157,25 @@ During reading cache all that happens is reading rows from sqlite and mapping th
I haven't set up proper benchmarks/performance regressions yet, so don't want to make specific claims, however that would almost certainly make your programm faster if computations take more than several seconds.


If you want to experiment for youself, check out [tests.test_many](src/cachew/tests/test_cachew.py#L286)
If you want to experiment for youself, check out [tests.test_many](src/cachew/tests/test_cachew.py#L288)



# Using
See [docstring](src/cachew/__init__.py#L713) for up-to-date documentation on parameters and return types.
See [docstring](src/cachew/__init__.py#L701) for up-to-date documentation on parameters and return types.
You can also use [extensive unit tests](src/cachew/tests/test_cachew.py) as a reference.

Some useful (but optional) arguments of `@cachew` decorator:

* `cache_path` can be a directory, or a callable that [returns a path](src/cachew/tests/test_cachew.py#L377) and depends on function's arguments.
* `cache_path` can be a directory, or a callable that [returns a path](src/cachew/tests/test_cachew.py#L379) and depends on function's arguments.

By default, `settings.DEFAULT_CACHEW_DIR` is used.

* `depends_on` is a function which determines whether your inputs have changed, and the cache needs to be invalidated.

By default it just uses string representation of the arguments, you can also specify a custom callable.

For instance, it can be used to [discard cache](src/cachew/tests/test_cachew.py#L92) if the input file was modified.
For instance, it can be used to [discard cache](src/cachew/tests/test_cachew.py#L93) if the input file was modified.

* `cls` is the type that would be serialized.

Expand Down Expand Up @@ -260,7 +260,7 @@ Now you can use `@mcachew` in place of `@cachew`, and be certain things don't br
## Settings


[cachew.settings](src/cachew/__init__.py#L64) exposes some parameters that allow you to control `cachew` behaviour:
[cachew.settings](src/cachew/__init__.py#L57) exposes some parameters that allow you to control `cachew` behaviour:
- `ENABLE`: set to `False` if you want to disable caching for without removing the decorators (useful for testing and debugging).
You can also use [cachew.extra.disabled_cachew](src/cachew/__init__.py#L18) context manager to do it temporarily.
- `DEFAULT_CACHEW_DIR`: override to set a different base directory. The default is the "user cache directory" (see [appdirs docs](https://github.com/ActiveState/appdirs#some-example-output)).
Expand Down
2 changes: 1 addition & 1 deletion readme.tpl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{# disable code used to generate readme #}
{# based on https://stackoverflow.com/a/55305881/706389 #}

{%- extends 'markdown.tpl' -%}
{%- extends 'markdown/index.md.j2' -%}

{% block input_group %}
{%- if cell.metadata.get('nbconvert', {}).get('show_code', False) -%}
Expand Down

0 comments on commit 6fdd070

Please sign in to comment.