pub struct AiResultCache { /* private fields */ }Expand description
foyer-backed in-memory cache of per-row inference results.
foyer::Cache is internally sharded and lock-free on the read path, so
AiResultCache is Send + Sync.
Implementations§
Source§impl AiResultCache
impl AiResultCache
Sourcepub fn new(config: AiResultCacheConfig) -> Self
pub fn new(config: AiResultCacheConfig) -> Self
Create a cache with the given configuration.
Sourcepub fn with_defaults() -> Self
pub fn with_defaults() -> Self
Create a cache with default configuration.
Sourcepub fn get(&self, key: &AiCacheKey) -> Option<CachedOutput>
pub fn get(&self, key: &AiCacheKey) -> Option<CachedOutput>
Look up a cached result, recording a hit or miss.
Sourcepub fn insert(&self, key: AiCacheKey, value: CachedOutput)
pub fn insert(&self, key: AiCacheKey, value: CachedOutput)
Insert or update a cached result.
Sourcepub fn miss_count(&self) -> u64
pub fn miss_count(&self) -> u64
Total cache misses since creation.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for AiResultCache
impl !RefUnwindSafe for AiResultCache
impl Send for AiResultCache
impl Sync for AiResultCache
impl Unpin for AiResultCache
impl UnsafeUnpin for AiResultCache
impl !UnwindSafe for AiResultCache
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more