Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cacheia_decorators-1.0.0.post3.tar.gz (2.5 kB view hashes)

Uploaded Source

Built Distribution

cacheia_decorators-1.0.0.post3-py3-none-any.whl (3.2 kB view hashes)

Uploaded Python 3

Supported by

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