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
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
Built Distribution
File details
Details for the file cacheia_decorators-1.0.0.post3.tar.gz
.
File metadata
- Download URL: cacheia_decorators-1.0.0.post3.tar.gz
- Upload date:
- Size: 2.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4a7472bfde6062474605cacdaa94e282b9054e65105e2121b9dffdc070a52ee6 |
|
MD5 | 75d34c9a5732427d5c8ee22fe7e5096e |
|
BLAKE2b-256 | cae65a5799c62dbc6eebcd9dd57f4bfe535fb9dee3bd45ac0640a2b7bbca34d3 |
File details
Details for the file cacheia_decorators-1.0.0.post3-py3-none-any.whl
.
File metadata
- Download URL: cacheia_decorators-1.0.0.post3-py3-none-any.whl
- Upload date:
- Size: 3.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7503b4c10c494026bf4190edd95c1b6a740dd125f62f23e9f52030e4cd8fcfd1 |
|
MD5 | d6fbaf70d8f97ac282c1cc04f244a369 |
|
BLAKE2b-256 | 60d4b5a6fc94e19164a1f8f3c2ed62c06db5d31c9e3afbda7533148ec0bb52ed |