pub struct CacheEntry<T> {
pub data: T,
pub size_bytes: usize,
pub last_accessed: Instant,
pub access_count: u64,
pub priority: u32,
pub created_at: Instant,
pub expires_at: Option<Instant>,
}Expand description
Cache entry with metadata
Fields§
§data: TThe cached data
size_bytes: usizeSize in bytes
last_accessed: InstantLast access time
access_count: u64Access count
priority: u32Priority (higher = more important to keep)
created_at: InstantCreation time
expires_at: Option<Instant>Expiry time (None = never expires)
Implementations§
Source§impl<T> CacheEntry<T>
impl<T> CacheEntry<T>
Sourcepub fn mark_accessed(&mut self)
pub fn mark_accessed(&mut self)
Mark as accessed
Sourcepub fn is_expired(&self) -> bool
pub fn is_expired(&self) -> bool
Check if expired
Sourcepub fn age_seconds(&self) -> f64
pub fn age_seconds(&self) -> f64
Get age in seconds
Sourcepub fn idle_seconds(&self) -> f64
pub fn idle_seconds(&self) -> f64
Get time since last access in seconds
Trait Implementations§
Source§impl<T: Clone> Clone for CacheEntry<T>
impl<T: Clone> Clone for CacheEntry<T>
Auto Trait Implementations§
impl<T> Freeze for CacheEntry<T>where
T: Freeze,
impl<T> RefUnwindSafe for CacheEntry<T>where
T: RefUnwindSafe,
impl<T> Send for CacheEntry<T>where
T: Send,
impl<T> Sync for CacheEntry<T>where
T: Sync,
impl<T> Unpin for CacheEntry<T>where
T: Unpin,
impl<T> UnsafeUnpin for CacheEntry<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for CacheEntry<T>where
T: UnwindSafe,
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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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