Skip to content

Latest commit

 

History

History
51 lines (37 loc) · 1.18 KB

README.md

File metadata and controls

51 lines (37 loc) · 1.18 KB

redis_cache Build Status Coverage Status

Implements high level function caching to Redis with a decorator

Install

pip install redis_cache_decorator

Usage

Setup

from redis_cache.redis_cache import RedisCache
r = RedisCache('localhost', 6379)

Cache

@r.cache()
def my_method(a, b, c):
  return a ** b ** c

Options

expiration: Number of seconds to keep the result in the cache. Defaults to 60 seconds when not specified.

e.g.

@r.cache(expiration=100)
def my_method():
  ...

signature_generator: Callable function that generates the signature to cache on. The default signature generator will be used if not specified.

e.g.

def sig_gen(*args, **kwargs):
  return "?".join(args)
  
r.cache(signature_generator=sig_gen)
def my_method():
  ...

Contributing

Check for any open issues, or open one yourself! All contributions are appreciated.

Tests

nosetests