pub struct CacheEntry<T> {
pub value: T,
pub created_at: SystemTime,
pub last_accessed: SystemTime,
pub access_count: u64,
pub ttl: Option<Duration>,
pub stale_while_revalidate: Option<Duration>,
pub tags: Vec<String>,
pub dependencies: Vec<String>,
pub cost: u64,
pub size: usize,
pub etag: Option<String>,
pub version: u64,
}Expand description
A cached entry with full metadata
Fields§
§value: TThe cached value
created_at: SystemTimeWhen the entry was created
last_accessed: SystemTimeWhen the entry was last accessed
access_count: u64Number of times accessed
ttl: Option<Duration>Time-to-live
stale_while_revalidate: Option<Duration>Stale-while-revalidate duration
Associated tags
dependencies: Vec<String>Dependency keys
cost: u64Computation cost
size: usizeSize in bytes
etag: Option<String>ETag for HTTP caching
version: u64Version for optimistic concurrency
Implementations§
Source§impl<T> CacheEntry<T>
impl<T> CacheEntry<T>
Sourcepub fn new(value: T, size: usize) -> CacheEntry<T>
pub fn new(value: T, size: usize) -> CacheEntry<T>
Create a new cache entry
Sourcepub fn with_ttl(value: T, size: usize, ttl: Duration) -> CacheEntry<T>
pub fn with_ttl(value: T, size: usize, ttl: Duration) -> CacheEntry<T>
Create entry with TTL
Sourcepub fn is_expired(&self) -> bool
pub fn is_expired(&self) -> bool
Check if entry has expired
Sourcepub fn ttl_remaining(&self) -> Option<Duration>
pub fn ttl_remaining(&self) -> Option<Duration>
Get remaining TTL
Trait Implementations§
Source§impl<T> Clone for CacheEntry<T>where
T: Clone,
impl<T> Clone for CacheEntry<T>where
T: Clone,
Source§fn clone(&self) -> CacheEntry<T>
fn clone(&self) -> CacheEntry<T>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<T> Debug for CacheEntry<T>where
T: Debug,
impl<T> Debug for CacheEntry<T>where
T: Debug,
Source§impl<'de, T> Deserialize<'de> for CacheEntry<T>where
T: Deserialize<'de>,
impl<'de, T> Deserialize<'de> for CacheEntry<T>where
T: Deserialize<'de>,
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<CacheEntry<T>, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<CacheEntry<T>, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl<T> Serialize for CacheEntry<T>where
T: Serialize,
impl<T> Serialize for CacheEntry<T>where
T: Serialize,
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
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> 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