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

Uploaded Source

Built Distribution

outcome_utils-4.12.1-py3-none-any.whl (16.4 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for outcome-utils-4.12.1.tar.gz
Algorithm Hash digest
SHA256 4a57b0804daa4172b1a6749db61f397cd80b5b6bf6d01eb89d858d495ac900fd
MD5 ccc1b43399cec73dc040a96c305f4fd6
BLAKE2b-256 b6ebfde1b499cc5a25d3bef4c93a06598ae27543197e57f00d60956f4bceebac

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for outcome_utils-4.12.1-py3-none-any.whl
Algorithm Hash digest
SHA256 cda83e746ecff814363a43f4a8dae97103541f2a8e2c1312dac5cf58f08023fa
MD5 96413eef33531aa0e21163b881aca3fb
BLAKE2b-256 cc1a02e58915bb78458d6c929dfe4a40688f8fe87657f47adbf5db796524d000

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