Cache Alchemy CI Test Status Documentation Status

The Python Cache Toolkit.


$ pipenv install cache-alchemy

Only Python 3.6+ is supported.


import dataclasses

from redis import Redis

from cache_alchemy import memory_cache, json_cache, pickle_cache
from cache_alchemy.config import DefaultConfig

config = DefaultConfig()
config.cache_redis_client = Redis.from_url(config.CACHE_ALCHEMY_REDIS_URL)

class User:
    name: str

def get(name: str) -> User:
    return User(name=name)

def add(i: complex, j: complex) -> complex:
    return i + j

def add(i: int, j: int) -> int:
    return i + j


  • Distributed cache
  • Cache clear and partial clear with specific function parameter
  • Cache clear cascade by dependency
  • Cache Json Serializable function return value with json_cache
  • Cache Python Object function return value with pickle_cache
  • Cache any function return value with memory_cache
  • LRU Dict support