The Python Cache Toolkit.
Project description
Cache Alchemy
The Python Cache Toolkit.
Free software: MIT license
Documentation: https://cache-alchemy.readthedocs.io/en/latest/
Installation
$ pipenv install cache-alchemy
✨🍰✨
Only Python 3.6+ is supported.
Example
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)
@dataclasses.dataclass
class User:
name: str
@pickle_cache
def get(name: str) -> User:
return User(name=name)
@memory_cache
def add(i: complex, j: complex) -> complex:
return i + j
@json_cache
def add(i: int, j: int) -> int:
return i + j
Features
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 - behave like normal dict
TODO
History
0.4.* (2020)
Refactory redis cache to json cache
Support pickle Cache
Add backend class in function hash
0.2.* (2019)
Support Partially Clear Cache with Arguments
Support Flush Backend Cache
Cache Redis Client Must Decode Responses
0.1.* (2019)
Support Method and Property Cache
Support cache as a decorator with no arguments.
Init Project.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for cache_alchemy-0.4.2-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9e8a6dc98734915a478f3171e4cf2a8476909181610624ea18c29c54d7230a7f |
|
MD5 | 13ce90c46a4fb9cd84add66b16e07073 |
|
BLAKE2b-256 | 8643006f2d311ccd02633b49fc210a5c395936437d98ea0c8829a64d8f76b40a |