pub struct Metadata {
pub freq: u64,
pub created_at: u64,
pub ttl: Option<u64>,
}
Expand description
Contains additional information about a key, such as its access frequency and lifecycle.
NOTE: This struct derives Serialize and Deserialize to be stored as raw bytes (&u8) in the underlying sled tree.
Fields§
§freq: u64
The number of time the key has been accessed
created_at: u64
Timestamp of key creation, in seconds since the UNIX epoch
ttl: Option<u64>
The key’s time-to-live in seconds. If None, the key is persistent and never expires.
Implementations§
Source§impl Metadata
impl Metadata
Sourcepub fn new(ttl: Option<u64>) -> Metadata
pub fn new(ttl: Option<u64>) -> Metadata
Creates a new Metadata
instance with an optional TTL.
The created_at
timestamp is set to the current system time.
Sourcepub fn freq_incretement(self) -> Metadata
pub fn freq_incretement(self) -> Metadata
Increments the frequency counter.
Sourcepub fn freq_decretement(self) -> Metadata
pub fn freq_decretement(self) -> Metadata
Decrements the frequency counter.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Metadata
impl<'de> Deserialize<'de> for Metadata
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
impl StructuralPartialEq for Metadata
Auto Trait Implementations§
impl Freeze for Metadata
impl RefUnwindSafe for Metadata
impl Send for Metadata
impl Sync for Metadata
impl Unpin for Metadata
impl UnwindSafe for Metadata
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