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 (cache.max_entries, cache.default_ttl_seconds). Bring your own backend by implementing the CacheBackend protocol as a @component — it replaces the built-in automatically.

# application.yaml (optional)
cache:
  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.0.tar.gz (19.5 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.0-py3-none-any.whl (9.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pico_caching-0.1.0.tar.gz
  • Upload date:
  • Size: 19.5 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.0.tar.gz
Algorithm Hash digest
SHA256 2164d61a4089b8f091ff208cf27ce79d9c861c17ed6289fad564fd3f967a843e
MD5 19a811ca555dc53342214ad8583f6f9d
BLAKE2b-256 ca316c76d9827f72621ecacfb3ef0b248bcdc4a3fc2af0134e6869b5dbc96a01

See more details on using hashes here.

Provenance

The following attestation bundles were made for pico_caching-0.1.0.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.0-py3-none-any.whl.

File metadata

  • Download URL: pico_caching-0.1.0-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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4dc9348701a3438ffeffe9ddd4d87a9305d50ad920cb864bff4ecfa6d9dfc4bf
MD5 57591eb2f0b4b705ac4547fb7f52b0d9
BLAKE2b-256 8ebcfe8a412d139c36d72a4110222653ea50d6c4a2324473a7ac014e147609e3

See more details on using hashes here.

Provenance

The following attestation bundles were made for pico_caching-0.1.0-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