Skip to main content

redis based cache_clear() for lru_cache

Project description

lru_cache_pubsub_cache_clear

lru_cache_pubsub_cache_clear is a decorator to broadcast cache_clear() calls to lru_cache across multiple instances of an application. This allows for local cache access speed and redis-like centralized cache invalidation. Example:

from lru_cache_pubsub_cache_clear.decorators import lru_cache_pubsub_cache_clear
from django_redis import get_redis_connection


@lru_cache_pubsub_cache_clear(get_redis_connection=get_redis_connection,
                              channel_name='CHANNEL_CACHE_CLEAR')
@lru_cache(maxsize=1000000)
def get_data(key)
    ...
    return value

Here get_redis_connection is a callable which returns a redis connection (e.g. django_redis.get_redis_connection).

Then every time one of app instances calls get_data.cache_clear() it will be executed on all connected instances.

Project details


Download files

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

Files for lru-cache-pubsub-cache-clear, version 0.0.9
Filename, size File type Python version Upload date Hashes
Filename, size lru_cache_pubsub_cache_clear-0.0.9-py3-none-any.whl (3.5 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size lru-cache-pubsub-cache-clear-0.0.9.tar.gz (1.9 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