Skip to main content

Decorates for Cacheia library that allows invalidation and other shenanigans

Project description

Cacheia Decorators

Exposes decorators that can be used along FastAPI and plain functions to cache responses using cacheia machinery.

Installation

Install decorators with "schemas" optional and "local" and "remote" cache support:

pip install -e ./decorators[schemas,local,remote]

Code

There are these decorators avaialble:

  • local.cache: which can be used on plain functions to cache values using a local cache or cacheia_client.
  • remote.cache: which can be used to cache values on a remote instance of cacheia (i.e. cacheia_api service).

Usage

from cacheia_decorators.local import cache as local_cache
from cacheia_decorators.remote import cache as remote_cache


@local_cache(key_builder=lambda i: str(i == 0), settings={})
def function_a():
    return "Hello World"

@remote_cache(key_builder=lambda i: str(i == 0), url="http://localhost:5000/")
def function_b():
    return "Hello World"

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cacheia_decorators-1.0.0.post3.tar.gz (2.5 kB view details)

Uploaded Source

Built Distribution

cacheia_decorators-1.0.0.post3-py3-none-any.whl (3.2 kB view details)

Uploaded Python 3

File details

Details for the file cacheia_decorators-1.0.0.post3.tar.gz.

File metadata

File hashes

Hashes for cacheia_decorators-1.0.0.post3.tar.gz
Algorithm Hash digest
SHA256 4a7472bfde6062474605cacdaa94e282b9054e65105e2121b9dffdc070a52ee6
MD5 75d34c9a5732427d5c8ee22fe7e5096e
BLAKE2b-256 cae65a5799c62dbc6eebcd9dd57f4bfe535fb9dee3bd45ac0640a2b7bbca34d3

See more details on using hashes here.

File details

Details for the file cacheia_decorators-1.0.0.post3-py3-none-any.whl.

File metadata

File hashes

Hashes for cacheia_decorators-1.0.0.post3-py3-none-any.whl
Algorithm Hash digest
SHA256 7503b4c10c494026bf4190edd95c1b6a740dd125f62f23e9f52030e4cd8fcfd1
MD5 d6fbaf70d8f97ac282c1cc04f244a369
BLAKE2b-256 60d4b5a6fc94e19164a1f8f3c2ed62c06db5d31c9e3afbda7533148ec0bb52ed

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