filesystem¶
Summary¶
|
Backend that stores cached responses as files on the local filesystem. |
|
A dictionary-like interface to files on the local filesystem |
Module Contents¶
- class FileBackend(cache_name='http_cache', use_temp=False, **kwargs)¶
Bases:
aiohttp_client_cache.backends.base.CacheBackend
Backend that stores cached responses as files on the local filesystem. Response paths will be in the format
<cache_name>/responses/<cache_key>
. Redirects are stored in a SQLite database, located at<cache_name>/redirects.sqlite
.
- class FileCache(cache_name, use_temp=False, **kwargs)¶
Bases:
aiohttp_client_cache.backends.base.BaseCache
A dictionary-like interface to files on the local filesystem
- Parameters
use_temp (bool) –
- _abc_impl = <_abc_data object>¶
- _join(key)¶
- _try_io(ignore_errors=True)¶
Attempt an I/O operation, and either ignore errors or re-raise them as KeyErrors
- Parameters
ignore_errors (bool) –
- async clear()¶
Note: Currently this is a blocking operation
- 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
- paths()¶
Get file paths to all cached responses
- 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, value)¶
Write an item to the cache
- Parameters
key (str) –
value (Optional[Union[aiohttp_client_cache.response.CachedResponse, bytes, str]]) –
- _get_cache_dir(cache_dir, use_temp)¶
- Return type
- Parameters
cache_dir (Union[pathlib.Path, str]) –
use_temp (bool) –