redis¶
Summary¶
|
|
|
An async interface for caching objects in Redis. |
Module Contents¶
- class RedisBackend(cache_name='aiohttp-cache', address='redis://localhost', **kwargs)¶
Bases:
CacheBackend
Async cache backend for Redis
Notes
Requires redis-py
Accepts keyword arguments for
redis.asyncio.client.Redis
- Parameters:
cache_name (
str
) – Used as a namespace (prefix for hash key)address (
str
) – Redis server URIkwargs (
Any
) – Additional keyword arguments forCacheBackend
or backend connection
- class RedisCache(namespace, collection_name, address='redis://localhost', connection=None, **kwargs)¶
Bases:
BaseCache
An async interface for caching objects in Redis.
- Parameters:
Note: The hash key name on the redis server will be
namespace:collection_name
.- async clear()¶
Delete all items from the cache
- async close()¶
Close any active connections, if applicable
- async delete(key)¶
Delete an item from the cache. Does not raise an error if the item is missing.
- Parameters:
key (
str
)
- async get_connection()¶
Lazy-initialize redis connection
- async keys()¶
Get all keys stored in the cache
- Return type:
- async read(key)¶
Read an item from the cache. Returns
None
if the item is missing.
- async values()¶
Get all values stored in the cache
- Return type: