A collection of python utils.
Project description
utils-py
A set of python utilities.
Usage
poetry add outcome-utils
Cache
To add cache to a module
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:
@region.cache_on_arguments()
def func_to_cache():
...
Or for async functions:
@region.cache_on_arguments()
@cache.cache_async
async def async_func_to_cache():
...
To have the cache persist on disk, specify the path
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
outcome-utils-4.25.1.tar.gz
(18.2 kB
view hashes)
Built Distribution
Close
Hashes for outcome_utils-4.25.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0c89e1e8838354827bd4941dcd96116d8e795748676f5877f7c218f1c968eab0 |
|
MD5 | 1a9d9bbccfbced3253269bda729c8285 |
|
BLAKE2b-256 | 4fa53faebbcaa50fcedfc6b3d0518ddf5034b28de4f0f8470c3d6840f3048f36 |