You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

cacheia-decorators

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cacheia-decorators

Decorates for Cacheia library that allows invalidation and other shenanigans

1.0.0.post3
pipPyPI
Maintainers
1

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"

Keywords

cache

FAQs

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts