Skip to main content

Module cache

Module cache 

Source
Expand description

XDG disk cache for successful HTTP GET bodies between process invocations.

Cache key = SHA-256(url || NUL || parser_version || NUL || accept). Each entry stores body bytes plus metadata with body checksum; corrupt or expired entries are discarded and re-fetched.

Budget: optional max_bytes evicts oldest entries after each successful put. ttl == 0 means entries never hit (always re-fetch).

Poisoned-entry guards: body reads are capped by HARD_MAX_BODY_BYTES (and the cache soft budget); meta JSON reads are capped by MAX_CACHE_META_BYTES. Both paths use fallible try_reserve_exact before filling buffers (never unbounded fs::read / fs::read_to_string on attacker-controlled sizes).

Structs§

CacheClearResult
Result of cache clear.
CacheStats
Aggregate cache inventory for cache stats / doctor.
DiskCache
Disk cache rooted at an XDG (or override) directory.

Constants§

CACHE_PARSER_VERSION
Bump when HTML/JSON parse semantics change so stale entries are ignored.
DEFAULT_CACHE_TTL_SECS
Default entry TTL (24 hours).
DEFAULT_MAX_CACHE_BYTES
Default on-disk budget (256 MiB). 0 means unlimited.
MAX_CACHE_META_BYTES
Hard ceiling for on-disk cache meta JSON (poisoned-entry guard).

Functions§

resolve_cache_dir
Resolve cache root: override, env, DOCSRS_CLI_HOME/cache, then XDG cache home.
resolve_cache_dir_with_source
Resolve cache root and report which layer won.