Skip to main content

The Python Cache Toolkit.

Project description

Cache Alchemy

https://img.shields.io/pypi/v/cache-alchemy.svg CI Test Status Documentation Status https://img.shields.io/pypi/pyversions/cache-alchemy.svg https://codecov.io/gh/GuangTianLi/cache-alchemy/branch/master/graph/badge.svg https://img.shields.io/badge/code%20style-black-000000.svg

The Python Cache Toolkit.

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

TODO

History

0.4.* (2020)

  • Refactory redis cache to json cache

  • Support pickle Cache

  • Add backend class in function hash

  • Add cache key prefix to avoid key conflict

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


Download files

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

Source Distribution

cache-alchemy-0.4.5.tar.gz (22.3 kB view hashes)

Uploaded Source

Built Distribution

cache_alchemy-0.4.5-py2.py3-none-any.whl (13.5 kB view hashes)

Uploaded Python 2 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