mobacache is a pythonic interface for creating a cache over redis or other provider. It provides simple decorators that can be added to any function to cache its return values.
MIT License
mobacache is a pythonic interface for creating a cache over redis. It provides simple decorators that can be added to any function to cache its return values.
Python 2.7+
pip install moba-cache
or to get the latest version
git clone https://github.com/redrush85/mobacache.git
cd mobacache
python setup.py install
from mobacache import CacheBuilder
import redis
redis_conn = redis.StrictRedis()
cb = CacheBuilder(redis_conn)
@cb.cache(ttl=10)
def my_method(a=1, b=2, c=0):
return a + b + c
@cb.advance_cache(key_format="{a}:{b}:var_c={c}", ttl=10)
def my_method(a=0, b=0, c=0):
return a + b + c
my_method(1, 2, 3)
data = cb.get("1:2:var_c=3")
print(data) # 6
python -m unittest