gridfs¶
Summary¶
|
An async-compatible interface for caching objects in MongoDB GridFS. |
|
A dictionary-like interface for MongoDB GridFS |
Module Contents¶
- class GridFSBackend(cache_name='aiohttp-cache', connection=None, **kwargs)¶
Bases:
aiohttp_client_cache.backends.base.CacheBackend
An async-compatible interface for caching objects in MongoDB GridFS. Use this if you need to support documents greater than 16MB.
- Parameters
connection (
Optional
[MongoClient
]) – Optional client object to use instead of creating a new onecache_name (str) –
expire_after (Union[None, int, float, str, datetime.datetime, datetime.timedelta]) –
urls_expire_after (Dict[str, Union[None, int, float, str, datetime.datetime, datetime.timedelta]]) –
allowed_codes (tuple) –
allowed_methods (tuple) –
include_headers (bool) –
ignored_params (Iterable) –
cache_control (bool) –
filter_fn (Callable) –
See
CacheBackend
for additional args.
- class GridFSCache(db_name, connection=None, **kwargs)¶
Bases:
aiohttp_client_cache.backends.base.BaseCache
A dictionary-like interface for MongoDB GridFS
- Parameters
db_name – database name (be careful with production databases)
connection (
Optional
[MongoClient
]) – MongoDB connection instance to use instead of creating a new one
- _abc_impl = <_abc_data object>¶
- async clear()¶
Delete all items from the cache
- async delete(key)¶
Delete an item from the cache. Does not raise an error if the item is missing.
- Parameters
key (str) –
- 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.
- values()¶
Get all values stored in the cache
- Return type
- async write(key, item)¶
Write an item to the cache
- Parameters
key (str) –
item (Optional[Union[aiohttp_client_cache.response.CachedResponse, bytes, str]]) –