LRU cache for Python. Use Redis as backend. Provides a dictionary-like object as well as a method decorator.
Project description
redis-lru
Installation
pip install redis-lru
Introduction
It’s often useful to have an lru redis cache. Of course, it’s also desirable not to have the cache grow too large, and cache expiration is often desirable. This module provides such a cache.
redis-lru supports CPython 3.4+
For the most part, you can just use it like this:
import redis
from redis_lru import RedisLRU
client = redis.StrictRedis()
cache = RedisLRU(client)
@cache
def f(x):
print("Calling f({})".format(x))
return x
f(3) # This will print "Calling f(3)", will return 3
f(3) # This will not print anything, but will return 3 (unless 15 minutes have passed between the first and second function call).
0.1.0
Refactor RedisLRU class for a clean and neat implement.
Stop supporting Python 2.
Fix bugs in test cases.
Added clean cache option at process exit.
0.0.4
Generate unique_key automatically so your may never get touch this argument.
Improved exception processing, now you won’t receive any exception by default.
Added unittest for redis_lru_cache decorator and RedisLRUCacheDict
Added more type of cache usage statistic type like POP, DEL etc.
Added changes log.
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
Built Distribution
Hashes for redis_lru-0.1.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ee2be8f0bc55d6778ef779586dd2f7e0546e0ff35411e72c986f570d8b1ecf6a |
|
MD5 | 46c3c7a742ab40d39d0ab45466ef3f27 |
|
BLAKE2b-256 | 0f9b2c2fc77a7aa1e43ac922781dc7ca162bf24ae636141d4bc3b1a2c83dd6bb |