aiohttp_client_cache.backends.gridfs module

class aiohttp_client_cache.backends.gridfs.GridFSBackend(cache_name='aiohttp-cache', connection=None, **kwargs)[source]

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 one

See CacheBackend for additional args.

class aiohttp_client_cache.backends.gridfs.GridFSCache(db_name, connection=None)[source]

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()[source]

Delete all items from the cache

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 keys()[source]

Get all keys stored in the cache

Return type

Iterable[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 size()[source]

Get the number of items in the cache

Return type

int

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