Metadata-Version: 2.4
Name: patera-caching
Version: 0.11.1
Summary: Response caching for Patera with in-memory, Redis and SQLite backends
Keywords: patera,cache,redis
Author: Marko Šterk
Author-email: Marko Šterk <marko_sterk@hotmail.com>
License-Expression: MIT
License-File: LICENSE
Classifier: Development Status :: 4 - Beta
Classifier: Framework :: AsyncIO
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Typing :: Typed
Classifier: Topic :: Internet :: WWW/HTTP :: Dynamic Content
Requires-Dist: cachetools>=7.0.5
Requires-Dist: patera>=0.121
Requires-Dist: redis>=5.0 ; extra == 'all'
Requires-Dist: aiosqlite>=0.20 ; extra == 'all'
Requires-Dist: redis>=5.0 ; extra == 'redis'
Requires-Dist: aiosqlite>=0.20 ; extra == 'sqlite'
Requires-Python: >=3.13
Project-URL: Homepage, https://github.com/MarkoSterk/Patera
Project-URL: Documentation, https://github.com/MarkoSterk/Patera#readme
Project-URL: Repository, https://github.com/MarkoSterk/Patera
Project-URL: Issues, https://github.com/MarkoSterk/Patera/issues
Project-URL: Changelog, https://github.com/MarkoSterk/Patera/blob/main/CHANGELOG.md
Provides-Extra: all
Provides-Extra: redis
Provides-Extra: sqlite
Description-Content-Type: text/markdown

# patera-caching

Response caching for Patera with in-memory, Redis and SQLite backends. Part of [Patera](https://github.com/MarkoSterk/Patera), a modular async-first Python web framework.

## Installation

```sh
pip install patera-caching
# or, with uv
uv add "patera[caching]"
```

Requires Python 3.13 or newer and `patera>=0.121`.

## Usage

`patera-caching` caches responses of endpoints:

```python
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](https://github.com/MarkoSterk/Patera#caching) for the full guide.

## License

MIT. See [LICENSE](https://github.com/MarkoSterk/Patera/blob/main/LICENSE).
