aiohttp_client_cache.backends.redis module¶
-
class
aiohttp_client_cache.backends.redis.
RedisBackend
(cache_name='aiohttp-cache', address='redis://localhost', **kwargs)[source]¶ Bases:
aiohttp_client_cache.backends.base.CacheBackend
Redis cache backend
-
class
aiohttp_client_cache.backends.redis.
RedisCache
(namespace, collection_name, address=None, connection=None, **kwargs)[source]¶ Bases:
aiohttp_client_cache.backends.base.BaseCache
An async-compatible interface for caching objects in Redis.
- Parameters
namespace (
str
) – namespace to usecollection_name (
str
) – name of the hash map stored in redisconnection (
Optional
[Redis
]) – An existing connection object to reuse instead of creating a new oneaddress (
Optional
[str
]) – Address of Redis serverkwargs – Additional keyword arguments for
redis.Redis
Note: The hash key name on the redis server will be
namespace:collection_name
.-
_abc_impl
= <_abc_data object>¶
-
async
contains
(key)[source]¶ Check if a key is stored in the cache
- Return type
bool
- Parameters
key (str) –
-
async
delete
(key)[source]¶ Delete a single item from the cache. Does not raise an error if the item is missing.
- Parameters
key (str) –
-
async
read
(key)[source]¶ Read a single item from the cache. Returns
None
if the item is missing.- Return type
Union
[CachedResponse
,None
,bytes
,str
]- Parameters
key (str) –
-
async
values
()[source]¶ Get all values stored in the cache
- Return type
Iterable
[Union
[CachedResponse
,None
,bytes
,str
]]
-
async
write
(key, item)[source]¶ Write an item to the cache
- Parameters
key (str) –
item (Union[aiohttp_client_cache.response.CachedResponse, None, bytes, str]) –