Cache#
Downloads are cached by content hash under $BOOKSHELF_CACHE_DIR. Pass a ContentCache as cache= to Bookshelf or AsyncBookshelf to move it for one client.
bookshelf.cache.ContentCache #
A small disk cache keyed only by canonical content hash.
get #
Return the cached path, or None when the hash is absent.
fetch #
Return the path of verified content, calling download only on a miss.
download writes the bytes to the path it is given. Concurrent fetches of one hash, across threads and processes, download it once. Bytes that do not match content_hash raise HashMismatchError and are never stored.
fetch_async async #
Return the path of verified content, awaiting download only on a miss.
The async twin of fetch, hashing and waiting on the lock off the event loop.
put #
Atomically store content under its hash and enforce the size cap.
stage #
Yield a unique staging path and atomically commit it on success.
summary #
Describe the cache: entry count, total bytes, age range and cap.
evict_lru #
Remove least recently used entries until the cache fits the cap.
max_bytes overrides the configured cap for this eviction only.