patera-caching
Response caching for Patera with in-memory, Redis and SQLite backends. Part of Patera, a modular async-first Python web framework.
Installation
pip install patera-caching
# or, with uv
uv add "patera[caching]"
Requires Python 3.13 or newer and patera>=0.121.
Usage
Only GET and HEAD are cached by default. Opt into POST explicitly with
@cache("PUBLIC_CACHE", methods=("POST",)) for read-only RPC operations; cache
hits skip the handler. Opted-in methods include a SHA-256 body digest in the key.
Default keys contain the handler's module and qualified name, method, path and
query. Existing entries with the former short-name keys expire naturally; update
manual invalidation patterns to include the qualified name.
key accepts a string or a sync/async callable taking Request. For example,
key=lambda req: f"page:{req.path}:{req.headers.get('accept-language', '')}"
separates language variants. A custom key replaces the default URL/handler key,
so include every relevant variation. Body digests and default user partitioning
still apply. User partitioning alone does not account for headers or other
request-dependent data.
patera-caching caches responses of endpoints:
from patera.caching import Caching, CachingConfig, cache
class PublicCache(Caching):
pass # in-memory backend by default
class Config(BaseConfig):
...
PUBLIC_CACHE: CachingConfig = CachingConfig(DURATION=60, MAX_SIZE=1000)
@path("/stats")
class StatsApi(Controller[App]):
@get("/")
@cache("PUBLIC_CACHE", duration=15) # registered name of the extension
async def stats(self, req: Request) -> Response:
return req.res.json(await compute_stats())
See the Caching section of the Patera documentation for the full guide.
License
MIT. See LICENSE.
Metadata
Release files for patera-caching 0.13.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| patera_caching-0.13.5.tar.gz | 12.7 kB | Without provenance | Details for patera_caching-0.13.5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| patera_caching-0.13.5-py3-none-any.whl | Python 3 | none | any | Details for patera_caching-0.13.5-py3-none-any.whl |
Total release size: 30.3 kB
Release files / patera_caching-0.13.5.tar.gz
| Download URL | patera_caching-0.13.5.tar.gz |
|---|---|
| Size | 12.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
99fa129c71238262e256b63faf5b1de693e0d6665b427fdf4b64314bb5a47769
|
|
BLAKE2b-256 checksum How to use checksums |
0a454d89b39656c7830fe99f2ba4af76d266685476f659082dcdf3a3bf628e84
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.14 {"installer":{"name":"uv","version":"0.11.14","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / patera_caching-0.13.5-py3-none-any.whl
| Download URL | patera_caching-0.13.5-py3-none-any.whl |
|---|---|
| Size | 17.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e16462978c12f091ad94d1072ab8d25d740267205cd6aa83a1a7debbd5ea20cb
|
|
BLAKE2b-256 checksum How to use checksums |
36c90ed98a22abab98ffdad31feaf503af0c14a9e5cb6520a0da74a73c32a7a3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.14 {"installer":{"name":"uv","version":"0.11.14","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for patera-caching 0.13.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.