pub struct GeneratorCache { /* private fields */ }Expand description
Generator cache. Held inside the registry; owned by the registry because cache invalidation hooks into registry mutations (registering a new command bumps the commands generator’s version, naturally invalidating cached entries via the new key).
Implementations§
Source§impl GeneratorCache
impl GeneratorCache
pub fn new() -> Self
Sourcepub fn get(&self, key: &CacheKey) -> Option<Vec<RawCandidate>>
pub fn get(&self, key: &CacheKey) -> Option<Vec<RawCandidate>>
Return cached candidates for key if present and not
expired. Caller is responsible for cloning if it needs the
returned Vec to outlive the cache; this signature returns
an owned clone to avoid lock-poisoning footguns.
Sourcepub fn put(&self, key: CacheKey, candidates: Vec<RawCandidate>, ttl: Duration)
pub fn put(&self, key: CacheKey, candidates: Vec<RawCandidate>, ttl: Duration)
Store candidates under key with the given soft TTL.
Sourcepub fn invalidate(&self, key: &CacheKey)
pub fn invalidate(&self, key: &CacheKey)
Remove an entry. Used by tests and future explicit- invalidation paths.
Sourcepub fn clear(&self)
pub fn clear(&self)
Drop every cached entry. Used by clear-completion-cache
command (post-1.0) and in tests.
Sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
How many entries are currently cached. For tests + a future
:cache-stats command.