gridfs

Summary

GridFSBackend([cache_name, connection])

An async-compatible interface for caching objects in MongoDB GridFS.

GridFSCache(db_name[, connection])

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 one

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 contains(key)

Check if a key is stored in the cache

Return type

bool

Parameters

key (str) –

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

AsyncIterable[str]

async read(key)

Read an item from the cache. Returns None if the item is missing.

Return type

Union[CachedResponse, bytes, str, None]

Parameters

key (str) –

async size()

Get the number of items in the cache

Return type

int

values()

Get all values stored in the cache

Return type

AsyncIterable[Union[CachedResponse, bytes, str, None]]

async write(key, item)

Write an item to the cache

Parameters