Skip to main content

Declarative caching for the Pico ecosystem: @cacheable AOP with pluggable backends.

Project description

📦 pico-caching

PyPI Ask DeepWiki License: MIT CI (tox matrix) codecov Quality Gate Status Duplicated Lines (%) Maintainability Rating PyPI Downloads Docs Interactive Lab

Declarative method caching for the Pico ecosystem: @cacheable over pico-ioc method interception, pluggable backends, auto-discovered by pico-boot. Zero-config.

Install

pip install pico-caching

Use

from pico_ioc import component
from pico_caching import cacheable

@component
class UserRepo:
    @cacheable(ttl_seconds=60)
    async def find(self, user_id: int): ...

    @cacheable(key=lambda q: f"search:{q}")
    def search(self, q: str): ...

Sync and async (the awaited result is cached, never the coroutine). Default backend: thread-safe in-memory LRU with per-entry TTL (caching.max_entries, caching.default_ttl_seconds). Bring your own backend by implementing the CacheBackend protocol as a @component — it replaces the built-in automatically.

# application.yaml (optional)
caching:
  default_ttl_seconds: 300
  max_entries: 1024

Skipped for now: @cache_evict and a Redis backend — planned once real usage asks for them.

Documentation

Full docs at dperezcabrera.github.io/pico-caching.

License

MIT

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

pico_caching-0.1.1.tar.gz (19.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pico_caching-0.1.1-py3-none-any.whl (9.1 kB view details)

Uploaded Python 3

File details

Details for the file pico_caching-0.1.1.tar.gz.

File metadata

  • Download URL: pico_caching-0.1.1.tar.gz
  • Upload date:
  • Size: 19.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pico_caching-0.1.1.tar.gz
Algorithm Hash digest
SHA256 b140d57dc958548ffcbf540c49ae4faaefd982a3d94c66b3809acef9898bc73c
MD5 c6ff2aeddfea1f2fe8719c947469511c
BLAKE2b-256 9301d467f4531b9a9d64ae47ff505f0d01f2e56d8cd16c1306a883b895d7c83f

See more details on using hashes here.

Provenance

The following attestation bundles were made for pico_caching-0.1.1.tar.gz:

Publisher: publish-to-pypi.yml on dperezcabrera/pico-caching

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pico_caching-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: pico_caching-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 9.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pico_caching-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a6ad96b066facff81752e6a17db36f0bad81529c9b4d013bddeee095149f4218
MD5 29e38950212c4947a80c3c30528ca724
BLAKE2b-256 45f6ea4d3e628a25835adfb9c050d19afa9e5c9669ec20f9b70a7cdda493883f

See more details on using hashes here.

Provenance

The following attestation bundles were made for pico_caching-0.1.1-py3-none-any.whl:

Publisher: publish-to-pypi.yml on dperezcabrera/pico-caching

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page