Install via pip:
pip install hug_store_redis
This is how you create a Redis store:
from hug_store_redis import RedisStore store = RedisStore(connection, namespace='sessions', expiration=3600)
The arguments are as follows:
connection: A connection object to the Redis server. This module installs
the official redis module, but you can
use your client of choice thanks to Python's duck typing. If you just want to
get started quickly, use:
import redis; connection = redis.StrictRedis().
namespace: A prefix for the keys which will be saved in Redis. If you
sessions, the full key will be
expiration: Expiration time of each key in seconds. Will be reset on every
If you want to use this store with hug's session middleware, this is how:
middleware = SessionMiddleware(store) __hug__.http.add_middleware(middleware)
Remember that the
__hug__ object is only available after the first time a hug
decorator has been executed.
The API implements the hug API for external stores.
set(key, data): JSON-encode
dataand save it for the given
get(key): JSON-decode data for the given
keyand return it. Raises
hug.exceptions.StoreKeyNotFoundif the key does not exist.
exists(key): Return whether the given
keyexists or not.
delete(key): Delete the given
hug_store_redis is written and maintained by Fabian Kochem.