Metadata-Version: 2.1
Name: outcome-utils
Version: 4.15.0
Summary: A collection of python utils.
Home-page: https://github.com/outcome-co/utils-py
License: ISC
Author: Douglas Willcocks
Author-email: douglas@outcome.co
Requires-Python: >=3.8.6,<3.9.0
Classifier: License :: OSI Approved
Classifier: Programming Language :: Python :: 3
Requires-Dist: asgiref (>=3.2.10,<4.0.0)
Requires-Dist: cachetools (>=4.1.1,<5.0.0)
Requires-Dist: colored (>=1.4.2,<2.0.0)
Requires-Dist: dogpile.cache (>=1.0.2,<2.0.0)
Requires-Dist: jinja2 (>=2.11.2,<3.0.0)
Requires-Dist: makefun (>=1.9.3,<2.0.0)
Requires-Dist: pyfakefs (>=4.1.0,<5.0.0)
Requires-Dist: requests (>=2.24.0,<3.0.0)
Requires-Dist: rich (>=6.2,<10.0)
Requires-Dist: semver (>=2.10.2,<3.0.0)
Requires-Dist: toml (>=0.10.1,<0.11.0)
Project-URL: Documentation, https://github.com/outcome-co/utils-py#README
Project-URL: Repository, https://github.com/outcome-co/utils-py
Description-Content-Type: text/markdown

# utils-py
![ci-badge](https://github.com/outcome-co/utils-py/workflows/Release/badge.svg?branch=v4.15.0) ![version-badge](https://img.shields.io/badge/version-4.15.0-brightgreen)

A set of python utilities.

## Usage

```sh
poetry add outcome-utils
```

### Cache

To add cache to a module
``` python
from outcome.utils import cache

cache_settings = {
    '<your_prefix>.expiration': 300,  # Default
    '<your_prefix>.backend': 'memory',  # Default
}

region = cache.get_cache_region()
cache.configure_cache_region(region, settings=cache_settings, prefix='<your_prefix>')
```

Then add to the functions to cache:
``` python
@region.cache_on_arguments()
def func_to_cache():
    ...
```

Or for async functions:
``` python
@region.cache_on_arguments()
@cache.cache_async
async def async_func_to_cache():
    ...
```

To have the cache persist on disk, specify the path
``` python
from pathlib import Path

cache_settings = {
    ...
    '<your_prefix>.cache_path': f'{Path.home()}/.cache/example_path/cache.pkl'',
    ...
}
```

## Development

Remember to run `./pre-commit.sh` when you clone the repository.

