redis¶
Summary¶
|
Async cache backend for Redis |
|
An async interface for caching objects in Redis. |
Module Contents¶
- class RedisBackend(cache_name='aiohttp-cache', address='redis://localhost', **kwargs)¶
Bases:
CacheBackendAsync 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 forCacheBackendor backend connection
- class RedisCache(namespace, collection_name, address='redis://localhost', connection=None, **kwargs)¶
Bases:
BaseCacheAn 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
Noneif the item is missing.- Parameters:
key (
str)- Return type:
CachedResponse|bytes|str|None
- async values()¶
Get all values stored in the cache
- Return type:
AsyncIterable[CachedResponse|bytes|str|None]