Skip to main content

Pluggable cache adapter - one interface, swappable backends (in-memory, Redis).

Project description

kasper-cache

One cache interface, swappable backends. Switch from in-memory to Redis by changing a URL, not your code.

pip install kasper-cache          # in-memory
pip install "kasper-cache[redis]" # + Redis backend
from kasper_cache import Cache

cache = Cache.from_url("memory://")        # or "redis://localhost:6379/0"

cache.set("user:1", {"name": "Mallik"}, ttl=60)
cache.get("user:1")                        # -> {"name": "Mallik"}
cache.get_or_set("user:1", lambda: load(1), ttl=60)

@cache.memoize(ttl=30)
def expensive(x):
    ...

Why

  • One interface (get/set/delete/get_or_set/memoize) over many backends.
  • get_or_set guards against the thundering-herd on a cache miss.
  • In-memory is per-process and fast; Redis is shared and survives restarts.

MIT licensed.

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

kasper_cache-0.1.0.tar.gz (4.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

kasper_cache-0.1.0-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

Details for the file kasper_cache-0.1.0.tar.gz.

File metadata

  • Download URL: kasper_cache-0.1.0.tar.gz
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for kasper_cache-0.1.0.tar.gz
Algorithm Hash digest
SHA256 e5afa16b4448ff1bdfcb65f570ba5f3b2a6baae49dc411826e3eb0d40b4aa42d
MD5 c3521062ec0171a9e750807da46193b2
BLAKE2b-256 9605290473b9f3cb4a9bd5cd1bc504a742331134a6842f67800340709847aa6d

See more details on using hashes here.

File details

Details for the file kasper_cache-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: kasper_cache-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for kasper_cache-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4b8ff8ef80acd08229d18d1f76614237143136738839068da280086e7f64c0d8
MD5 f038006ad70d2eb21eade37c094a1b22
BLAKE2b-256 44d3c594a4f0b5c77828b48c80a4f306434fb386e1c9d91797774d6c6833416b

See more details on using hashes here.

Supported by

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