pub struct CacheRecord {
pub key: String,
pub value: Vec<u8>,
pub ttl_secs: u64,
pub priority: u32,
}Expand description
A single key-value record with optional metadata.
This is the unit of serialization: a collection of CacheRecords
represents a complete cache snapshot.
Fields§
§key: StringCache key.
value: Vec<u8>Raw value bytes.
ttl_secs: u64Optional TTL in seconds (0 means no TTL / immortal).
priority: u32Priority tag (higher = more important to keep on restore).
Implementations§
Source§impl CacheRecord
impl CacheRecord
Sourcepub fn new(key: impl Into<String>, value: Vec<u8>) -> Self
pub fn new(key: impl Into<String>, value: Vec<u8>) -> Self
Create a new CacheRecord with the given key and value, no TTL,
and default priority 0.
Sourcepub fn with_ttl(self, ttl_secs: u64) -> Self
pub fn with_ttl(self, ttl_secs: u64) -> Self
Set a TTL hint (seconds). A value of 0 means no TTL.
Sourcepub fn with_priority(self, priority: u32) -> Self
pub fn with_priority(self, priority: u32) -> Self
Set the priority tag.
Trait Implementations§
Source§impl Clone for CacheRecord
impl Clone for CacheRecord
Source§fn clone(&self) -> CacheRecord
fn clone(&self) -> CacheRecord
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 Debug for CacheRecord
impl Debug for CacheRecord
Source§impl PartialEq for CacheRecord
impl PartialEq for CacheRecord
impl Eq for CacheRecord
impl StructuralPartialEq for CacheRecord
Auto Trait Implementations§
impl Freeze for CacheRecord
impl RefUnwindSafe for CacheRecord
impl Send for CacheRecord
impl Sync for CacheRecord
impl Unpin for CacheRecord
impl UnsafeUnpin for CacheRecord
impl UnwindSafe for CacheRecord
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