pub struct CacheEntry<K, V, M = ()>{
pub key: K,
pub value: V,
pub metadata: M,
pub timestamp: DateTime<Utc>,
pub expiry: Option<DateTime<Utc>>,
pub access_count: u64,
pub last_accessed: DateTime<Utc>,
}Expand description
A cache entry containing a key-value pair with metadata
Fields§
§key: KThe cache key
value: VThe cached value
metadata: MOptional metadata associated with the entry
timestamp: DateTime<Utc>Timestamp when the entry was created
expiry: Option<DateTime<Utc>>Optional expiry time for TTL-based eviction
access_count: u64Number of times this entry has been accessed
last_accessed: DateTime<Utc>Last access timestamp
Implementations§
Source§impl<K, V, M> CacheEntry<K, V, M>
impl<K, V, M> CacheEntry<K, V, M>
Source§impl<K, V, M> CacheEntry<K, V, M>
impl<K, V, M> CacheEntry<K, V, M>
Sourcepub fn with_metadata(key: K, value: V, metadata: M) -> Self
pub fn with_metadata(key: K, value: V, metadata: M) -> Self
Create a new cache entry with metadata
Sourcepub fn is_expired(&self) -> bool
pub fn is_expired(&self) -> bool
Check if the entry has expired
Sourcepub fn record_access(&mut self)
pub fn record_access(&mut self)
Update access statistics
Trait Implementations§
Source§impl<K, V, M> Clone for CacheEntry<K, V, M>
impl<K, V, M> Clone for CacheEntry<K, V, M>
Source§fn clone(&self) -> CacheEntry<K, V, M>
fn clone(&self) -> CacheEntry<K, V, M>
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<K, V, M> Debug for CacheEntry<K, V, M>
impl<K, V, M> Debug for CacheEntry<K, V, M>
Source§impl<'de, K, V, M> Deserialize<'de> for CacheEntry<K, V, M>where
K: Clone + Hash + Eq + Deserialize<'de>,
V: Clone + Deserialize<'de>,
M: Clone + Deserialize<'de>,
impl<'de, K, V, M> Deserialize<'de> for CacheEntry<K, V, M>where
K: Clone + Hash + Eq + Deserialize<'de>,
V: Clone + Deserialize<'de>,
M: Clone + Deserialize<'de>,
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl<K, V, M> Searchable for CacheEntry<K, V, M>
Implement Searchable for common types
impl<K, V, M> Searchable for CacheEntry<K, V, M>
Implement Searchable for common types
Source§impl<K, V, M> Serialize for CacheEntry<K, V, M>
impl<K, V, M> Serialize for CacheEntry<K, V, M>
Auto Trait Implementations§
impl<K, V, M> Freeze for CacheEntry<K, V, M>
impl<K, V, M> RefUnwindSafe for CacheEntry<K, V, M>
impl<K, V, M> Send for CacheEntry<K, V, M>
impl<K, V, M> Sync for CacheEntry<K, V, M>
impl<K, V, M> Unpin for CacheEntry<K, V, M>
impl<K, V, M> UnsafeUnpin for CacheEntry<K, V, M>
impl<K, V, M> UnwindSafe for CacheEntry<K, V, M>
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