Skip to main content

safecache is a thread-safe and mutation-safe LRU cache for Python

Project description

Build Status

A thread-safe and mutation-safe LRU cache for Python.

Features

  • All cached entries are mutation-safe.
  • All cached entries are thread-safe.
  • Customizable cache-miss behavior.
  • Zero third-party dependencies.

Usage

safecache preserves the functools.lru_cache's API so no extra learning is needed.

To migrate from lru_cache to safecache, you can simply rename the decorators!

Before:

from functools import lru_cache

@lru_cache(maxsize=32, typed=True)
def function(*a, **kw):
    ...

After:

from safecache import safecache

@safecache(maxsize=32, typed=True)
def function(*a, **kw):
    ...

And now you get all the benefits of lru_cache with the enhancements of safecache.

For more advanced usage of safecache, please refer to the documentations.

FAQ

License

safecache is under MIT License.

Project details


Release history Release notifications

Download files

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

Files for safecache, version 0.4.0
Filename, size File type Python version Upload date Hashes
Filename, size safecache-0.4.0-py3-none-any.whl (5.8 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size safecache-0.4.0.tar.gz (4.2 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page