pub struct ShardStore { /* private fields */ }Expand description
A single shard’s key-value store.
Each worker thread owns exactly one ShardStore. All operations on it
are single-threaded — no locking required.
Implementations§
Source§impl ShardStore
impl ShardStore
Sourcepub fn set_max_memory(&mut self, bytes: usize)
pub fn set_max_memory(&mut self, bytes: usize)
Set the maximum memory limit for this shard (0 = unlimited).
Sourcepub fn max_memory(&self) -> usize
pub fn max_memory(&self) -> usize
Get the maximum memory limit for this shard.
Sourcepub fn entries_iter(&self) -> impl Iterator<Item = (&CompactKey, &KeyEntry)>
pub fn entries_iter(&self) -> impl Iterator<Item = (&CompactKey, &KeyEntry)>
Iterate over all entries in this shard.
Sourcepub fn get_entry(&self, key: &CompactKey) -> Option<&KeyEntry>
pub fn get_entry(&self, key: &CompactKey) -> Option<&KeyEntry>
Get a reference to a key entry.
Sourcepub fn get_bytes(&mut self, key: &[u8]) -> CommandResponse
pub fn get_bytes(&mut self, key: &[u8]) -> CommandResponse
Execute a GET operation against a borrowed key.
Sourcepub fn set_bytes(
&mut self,
key: &[u8],
value: &[u8],
ex: Option<u64>,
px: Option<u64>,
nx: bool,
xx: bool,
) -> CommandResponse
pub fn set_bytes( &mut self, key: &[u8], value: &[u8], ex: Option<u64>, px: Option<u64>, nx: bool, xx: bool, ) -> CommandResponse
Execute a SET-like operation against borrowed key and value bytes.
Sourcepub fn incr_by_bytes(&mut self, key: &[u8], delta: i64) -> CommandResponse
pub fn incr_by_bytes(&mut self, key: &[u8], delta: i64) -> CommandResponse
Execute INCRBY/DECRBY style mutation against a borrowed key.
Sourcepub fn get_entry_mut(&mut self, key: &CompactKey) -> Option<&mut KeyEntry>
pub fn get_entry_mut(&mut self, key: &CompactKey) -> Option<&mut KeyEntry>
Get a mutable reference to a key entry.
Sourcepub fn insert_entry(&mut self, key: CompactKey, entry: KeyEntry)
pub fn insert_entry(&mut self, key: CompactKey, entry: KeyEntry)
Insert a key entry directly (used by migration and restore paths).
Sourcepub fn mark_demoted(&mut self, key: &CompactKey, tier: u8, ref_hash: u64)
pub fn mark_demoted(&mut self, key: &CompactKey, tier: u8, ref_hash: u64)
Replace a key’s value with a tier reference after demotion.
Sourcepub fn promote(&mut self, key: &CompactKey, value: Value)
pub fn promote(&mut self, key: &CompactKey, value: Value)
Promote a key back to the hot tier with the given value.
Sourcepub fn evict_expired(&mut self) -> usize
pub fn evict_expired(&mut self) -> usize
Remove all expired keys, returning the count removed.
Sourcepub fn evict_expired_sample(&mut self, sample_size: usize) -> usize
pub fn evict_expired_sample(&mut self, sample_size: usize) -> usize
Remove expired keys by scanning a bounded sample of entries.
This avoids latency spikes from full-map sweeps on the hot path.
Sourcepub fn execute(&mut self, cmd: Command) -> CommandResponse
pub fn execute(&mut self, cmd: Command) -> CommandResponse
Execute a command on this shard and return the response.