pub struct ResolverCache { /* private fields */ }Expand description
Resolver cache. Stateless aside from the root path + TTL — every
lookup re-reads the filesystem, so multiple processes sharing the
same root see each other’s writes immediately (modulo the usual
caveats around concurrent fetches into the same directory; not a
concern at v1 since fetches run serially through boot_registry).
Implementations§
Source§impl ResolverCache
impl ResolverCache
Sourcepub fn new(root: impl Into<PathBuf>) -> Result<Self>
pub fn new(root: impl Into<PathBuf>) -> Result<Self>
Create a cache rooted at root with the default 24-hour TTL.
Creates the directory if it doesn’t exist (a missing cache
directory is normal on first run; not an error).
Sourcepub fn user_default() -> Result<Self>
pub fn user_default() -> Result<Self>
Create the per-user cache at $XDG_CACHE_HOME/lex/labels,
falling back to $HOME/.cache/lex/labels per XDG conventions.
Sourcepub fn default_root() -> PathBuf
pub fn default_root() -> PathBuf
Compute the default cache root without touching the
filesystem. Exposed so super::resolve_namespace can
surface the path in its ResolveError::CacheIo when
Self::user_default fails.
Sourcepub fn with_mutable_ttl(self, ttl: Duration) -> Self
pub fn with_mutable_ttl(self, ttl: Duration) -> Self
Override the mutable-rev TTL. Tests use this to force quick expiry without sleeping for 24 hours.
Sourcepub fn entry_path(&self, uri: &ParsedUri) -> PathBuf
pub fn entry_path(&self, uri: &ParsedUri) -> PathBuf
Cache directory for a URI. Deterministic; doesn’t touch the filesystem.
Sourcepub fn fetch_or_reuse(
&self,
uri: &ParsedUri,
fetcher: &dyn Fetcher,
) -> Result<PathBuf, ResolveError>
pub fn fetch_or_reuse( &self, uri: &ParsedUri, fetcher: &dyn Fetcher, ) -> Result<PathBuf, ResolveError>
Resolve uri against the cache, fetching via fetcher on a
cache miss or expired mutable entry. The caller-facing entry
point used by super::resolve_namespace_with.
Returns the cache directory containing the resolved schema
(or the subdir thereof, if the URI requested one — the
fetcher is responsible for honouring subdir).
Trait Implementations§
Source§impl Clone for ResolverCache
impl Clone for ResolverCache
Source§fn clone(&self) -> ResolverCache
fn clone(&self) -> ResolverCache
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more