Redis Backend

class cachelib.redis.RedisCache(host='localhost', port=6379, password=None, db=0, default_timeout=300, key_prefix=None, **kwargs)

Bases: BaseRedisCache

Uses the Redis key-value store as a cache backend.

The first argument can be either a string denoting address of the Redis server or an object resembling an instance of a redis.Redis class.

Note: Python Redis API already takes care of encoding unicode strings on the fly.

Parameters:
  • host (Any) – address of the Redis server or an object which API is compatible with the official Python Redis client (redis-py).

  • port (int) – port number on which Redis server listens for connections.

  • password (str | None) – password authentication for the Redis server.

  • db (int) – db (zero-based numeric index) on Redis Server to connect.

  • default_timeout (int) – the default timeout that is used if no timeout is specified on set(). A timeout of 0 indicates that the cache never expires.

  • key_prefix (str | Callable[[], str] | None) – A prefix that should be added to all keys.

  • kwargs (Any)

Any additional keyword arguments will be passed to redis.Redis.

serializer = <cachelib.serializers.RedisSerializer object>