pub struct FabricKvStore { /* private fields */ }Expand description
A key-value store backed by leased fabric resources.
The hot tier stores entries in a FabricHashMap over leased DRAM.
Each entry tracks creation time, TTL, and access count. The
tick() method evicts expired entries.
With the persistence feature, a cold tier backs overflow to block
storage. On a hot-tier miss, the cold tier is scanned and matching
entries are promoted back.
Implementations§
Source§impl FabricKvStore
impl FabricKvStore
Sourcepub fn put(&mut self, key: &[u8], value: &[u8]) -> Result<()>
pub fn put(&mut self, key: &[u8], value: &[u8]) -> Result<()>
Store a key-value pair with the default TTL.
Sourcepub fn put_with_ttl(
&mut self,
key: &[u8],
value: &[u8],
ttl_secs: u32,
) -> Result<()>
pub fn put_with_ttl( &mut self, key: &[u8], value: &[u8], ttl_secs: u32, ) -> Result<()>
Store a key-value pair with an explicit TTL in seconds.
Sourcepub fn get(&mut self, key: &[u8]) -> Result<Option<Vec<u8>>>
pub fn get(&mut self, key: &[u8]) -> Result<Option<Vec<u8>>>
Retrieve a value by key.
Checks the hot tier first. On a miss (with persistence enabled),
scans the cold tier and promotes the entry back to the hot tier.
Accessing a key refreshes its TTL (resets created_at to now).
Sourcepub fn delete(&mut self, key: &[u8]) -> Result<bool>
pub fn delete(&mut self, key: &[u8]) -> Result<bool>
Delete a key. Returns true if the key existed.
Sourcepub fn exists(&mut self, key: &[u8]) -> Result<bool>
pub fn exists(&mut self, key: &[u8]) -> Result<bool>
Check if a key exists (without reading the value).
Sourcepub fn ttl(&self, key: &[u8]) -> Result<Option<u32>>
pub fn ttl(&self, key: &[u8]) -> Result<Option<u32>>
Return the remaining TTL for a key in seconds, or None if the key
does not exist or is expired.
Sourcepub fn put_struct<T: Serialize>(&mut self, key: &[u8], value: &T) -> Result<()>
pub fn put_struct<T: Serialize>(&mut self, key: &[u8], value: &T) -> Result<()>
Store a serializable struct as a value.
Sourcepub fn put_struct_with_ttl<T: Serialize>(
&mut self,
key: &[u8],
value: &T,
ttl_secs: u32,
) -> Result<()>
pub fn put_struct_with_ttl<T: Serialize>( &mut self, key: &[u8], value: &T, ttl_secs: u32, ) -> Result<()>
Store a serializable struct with an explicit TTL.
Sourcepub fn get_struct<T: DeserializeOwned>(
&mut self,
key: &[u8],
) -> Result<Option<T>>
pub fn get_struct<T: DeserializeOwned>( &mut self, key: &[u8], ) -> Result<Option<T>>
Retrieve and deserialize a struct by key.