pub struct ProcessCache { /* private fields */ }Expand description
In-process moka-backed cache of Arc<SecretString>.
Constructed via ProcessCache::new, which requires a
HardeningToken. Cache operations are sync (no async runtime
involvement); moka’s eviction listener fires synchronously on Drop
in the sync flavor, so the Arc<SecretString> zeroize-on-Drop
semantics are preserved for evicted entries.
Implementations§
Source§impl ProcessCache
impl ProcessCache
Sourcepub fn new(
policy: &CachePolicy,
_token: HardeningToken,
audit_sink: Option<Arc<dyn AuditSink>>,
) -> Option<Self>
pub fn new( policy: &CachePolicy, _token: HardeningToken, audit_sink: Option<Arc<dyn AuditSink>>, ) -> Option<Self>
Construct a cache governed by policy. Returns None when the
policy is Disabled.
The _token parameter is the architectural lever: callers who
have not installed hardening cannot obtain a token and
therefore cannot construct a cache. The token is consumed by
value (it is Copy) and is not retained.
audit_sink, when provided, receives cache.expire events on
TTL-driven evictions. Explicit invalidate / invalidate_all
calls do not emit events here — Store emits its own
cache.clear on the user-facing path.
Sourcepub fn get(&self, key: &CacheKey) -> Option<Arc<SecretString>>
pub fn get(&self, key: &CacheKey) -> Option<Arc<SecretString>>
Read a cached value. Returns the Arc<SecretString> if a
fresh entry exists, or None on miss / TTL expiry. Callers
hold the clone — the cache retains its own Arc.
Sourcepub fn insert(&self, key: CacheKey, value: Arc<SecretString>)
pub fn insert(&self, key: CacheKey, value: Arc<SecretString>)
Insert or replace a value.
Sourcepub fn invalidate(&self, key: &CacheKey)
pub fn invalidate(&self, key: &CacheKey)
Invalidate a single entry. No-op if the key is absent.
Sourcepub fn invalidate_all(&self)
pub fn invalidate_all(&self)
Drop every entry. Used by hasp cache clear and tests.
Sourcepub fn run_pending_tasks(&self)
pub fn run_pending_tasks(&self)
Synchronously run pending eviction listeners. Used by tests to observe deterministic eviction behavior — production callers do not need to invoke this.
Sourcepub fn entry_count(&self) -> u64
pub fn entry_count(&self) -> u64
Approximate entry count after pending tasks are processed.
Useful for tests and --explain diagnostics; not authoritative
under concurrent insertion.
Trait Implementations§
Source§impl Clone for ProcessCache
impl Clone for ProcessCache
Source§fn clone(&self) -> ProcessCache
fn clone(&self) -> ProcessCache
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more