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, autoclose=True, **kwargs)¶
Bases:
CacheBackend
Backend that stores cached responses as files on the local filesystem.
Notes
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
.
- Parameters:
use_temp (
bool
) – Store cache files in a temp directory (e.g.,/tmp/http_cache/
). Note: ifcache_name
is an absolute path, this option will be ignored.autoclose (
bool
) – Close any active backend connections when the session is closedkwargs (
Any
) – Additional keyword arguments forCacheBackend
- class FileCache(cache_name, use_temp=False, **kwargs)¶
Bases:
BaseCache
A dictionary-like interface to files on the local filesystem
- async bulk_delete(keys)¶
Delete item(s) from the cache. Does not raise an error if the item is missing.
- Parameters:
keys (
set
)
- 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
)
- async keys()¶
Get all keys stored in the cache
- Return type:
- async paths()¶
Get file paths to all cached responses
- async read(key)¶
Read an item from the cache. Returns
None
if the item is missing.
- async values()¶
Get all values stored in the cache
- Return type: