Skip to main content

A collection of python utils.

Project description

utils-py

ci-badge version-badge

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.20.5.tar.gz (17.0 kB view details)

Uploaded Source

Built Distribution

outcome_utils-4.20.5-py3-none-any.whl (20.5 kB view details)

Uploaded Python 3

File details

Details for the file outcome-utils-4.20.5.tar.gz.

File metadata

  • Download URL: outcome-utils-4.20.5.tar.gz
  • Upload date:
  • Size: 17.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.10 CPython/3.8.6 Linux/5.4.0-1032-azure

File hashes

Hashes for outcome-utils-4.20.5.tar.gz
Algorithm Hash digest
SHA256 d45ad40039ca77bb400b54ffa61c6fafea9d74c3e82e77f349821600f88dd155
MD5 d31e4af91432c899b20f012613860fae
BLAKE2b-256 f353ba69e832be8e5ed563031de4ce6ab5f89bf0ece7a1e917224cef46d47a22

See more details on using hashes here.

File details

Details for the file outcome_utils-4.20.5-py3-none-any.whl.

File metadata

  • Download URL: outcome_utils-4.20.5-py3-none-any.whl
  • Upload date:
  • Size: 20.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.10 CPython/3.8.6 Linux/5.4.0-1032-azure

File hashes

Hashes for outcome_utils-4.20.5-py3-none-any.whl
Algorithm Hash digest
SHA256 ffaf2f957e52be4907f15e3b4fa1b9439a624ae311dcf155ef0ea18079267fb0
MD5 b5489a651ab8e3f71de10afda3de57e6
BLAKE2b-256 c465b4b1657c7e76dcc5c709052ae431d5ce8e954f0018ab5f3f2f85cd7150ad

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page