pub struct EntityCache { /* private fields */ }Expand description
Thread-safe entity cache with LRU eviction and TTL.
Implementations§
Source§impl EntityCache
impl EntityCache
Sourcepub fn get(&self, key: &EntityCacheKey) -> Option<String>
pub fn get(&self, key: &EntityCacheKey) -> Option<String>
Look up a cached entity.
Returns Some(data_json) on a hit, or None on a miss / expired entry.
Sourcepub fn put(&self, key: EntityCacheKey, entity: ResolvedEntity)
pub fn put(&self, key: EntityCacheKey, entity: ResolvedEntity)
Store a resolved entity with the default TTL.
Sourcepub fn put_with_ttl(
&self,
key: EntityCacheKey,
entity: ResolvedEntity,
ttl: Duration,
)
pub fn put_with_ttl( &self, key: EntityCacheKey, entity: ResolvedEntity, ttl: Duration, )
Store a resolved entity with an explicit TTL.
Sourcepub fn evict_expired(&self) -> usize
pub fn evict_expired(&self) -> usize
Remove expired entries.
Sourcepub fn stats(&self) -> EntityCacheStats
pub fn stats(&self) -> EntityCacheStats
Return cache statistics.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for EntityCache
impl RefUnwindSafe for EntityCache
impl Send for EntityCache
impl Sync for EntityCache
impl Unpin for EntityCache
impl UnsafeUnpin for EntityCache
impl UnwindSafe for EntityCache
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§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