pub struct FlatMap { /* private fields */ }Implementations§
Source§impl FlatMap
impl FlatMap
pub fn new() -> Self
pub fn from_entries( entries: impl IntoIterator<Item = StoredEntry>, now_ms: u64, ) -> Self
pub fn len(&self) -> usize
pub fn stored_bytes(&self) -> usize
pub fn memory_limit_bytes(&self) -> Option<usize>
pub fn eviction_policy(&self) -> EvictionPolicy
pub fn evictions(&self) -> u64
pub fn is_empty(&self) -> bool
pub fn configure_memory_policy( &mut self, memory_limit_bytes: Option<usize>, eviction_policy: EvictionPolicy, now_ms: u64, )
Source§impl FlatMap
impl FlatMap
pub fn delete(&mut self, key: &[u8], now_ms: u64) -> bool
pub fn delete_hashed(&mut self, hash: u64, key: &[u8], _now_ms: u64) -> bool
pub fn delete_hashed_local( &mut self, hash: u64, key: &[u8], now_ms: u64, ) -> bool
pub fn ttl_seconds(&mut self, key: &[u8], now_ms: u64) -> i64
pub fn ttl_millis(&mut self, key: &[u8], now_ms: u64) -> i64
pub fn persist(&mut self, key: &[u8], now_ms: u64) -> bool
pub fn expire(&mut self, key: &[u8], expire_at_ms: u64, now_ms: u64) -> bool
pub fn snapshot_entries(&self, now_ms: u64) -> Vec<StoredEntry>
pub fn process_maintenance(&mut self, now_ms: u64) -> usize
pub fn stats_snapshot( &self, ) -> (TierStatsSnapshot, TierStatsSnapshot, TierStatsSnapshot)
Source§impl FlatMap
impl FlatMap
pub fn get_ref_hashed_no_ttl(&mut self, hash: u64, key: &[u8]) -> Option<&[u8]>
&self read path. Skips entry access tracking (LFU/LRU touch). Safe for
any caller that does not depend on read-touch tracking — including the
shared-store hot path under RwLock::read.
Sourcepub fn has_no_ttl_entries(&self) -> bool
pub fn has_no_ttl_entries(&self) -> bool
Returns true when there are no TTL’d entries — caller can skip a
now_millis() call since no entries can expire.
Sourcepub fn get_value_bytes_hashed(
&self,
hash: u64,
key: &[u8],
now_ms: u64,
) -> Option<SharedBytes>
pub fn get_value_bytes_hashed( &self, hash: u64, key: &[u8], now_ms: u64, ) -> Option<SharedBytes>
Returns a refcount-only clone of the stored bytes::Bytes. Avoids the
Vec<u8> allocation that get_ref_hashed_shared callers do via
to_vec. Hot path for multi-direct GET.
pub fn get_value_bytes_hashed_prepared( &self, hash: u64, key: &[u8], key_tag: u64, now_ms: u64, ) -> Option<SharedBytes>
Sourcepub fn get_value_bytes_hashed_and_expire(
&mut self,
hash: u64,
key: &[u8],
expire_at_ms: u64,
now_ms: u64,
) -> Option<SharedBytes>
pub fn get_value_bytes_hashed_and_expire( &mut self, hash: u64, key: &[u8], expire_at_ms: u64, now_ms: u64, ) -> Option<SharedBytes>
Returns the current value and updates its expiration while holding the shard write lock. This is the native GETEX primitive.
Sourcepub fn with_value_bytes_hashed_and_expire<F>(
&mut self,
hash: u64,
key: &[u8],
expire_at_ms: u64,
now_ms: u64,
write: &mut F,
) -> bool
pub fn with_value_bytes_hashed_and_expire<F>( &mut self, hash: u64, key: &[u8], expire_at_ms: u64, now_ms: u64, write: &mut F, ) -> bool
Calls write with the current value and updates its expiration while
holding the shard write lock. This is the borrowed native GETEX path:
it avoids the Bytes refcount clone/drop pair needed by
get_value_bytes_hashed_and_expire.
pub fn get_ref_hashed_prepared_no_ttl( &mut self, hash: u64, key: &[u8], key_tag: u64, ) -> Option<&[u8]>
pub fn get_ref(&mut self, key: &[u8], now_ms: u64) -> Option<&[u8]>
pub fn get_ref_hashed( &mut self, hash: u64, key: &[u8], now_ms: u64, ) -> Option<&[u8]>
pub fn get_ref_hashed_local( &mut self, hash: u64, key: &[u8], now_ms: u64, ) -> Option<&[u8]>
pub fn get(&mut self, key: &[u8], now_ms: u64) -> Option<Bytes>
pub fn exists(&mut self, key: &[u8], now_ms: u64) -> bool
Sourcepub fn begin_read_epoch(&self)
pub fn begin_read_epoch(&self)
Starts a shard-local read epoch.
While at least one read epoch is active, value replacements and deletes retire old buffers instead of freeing them immediately. That keeps any zero-copy readers pointing at stable memory without introducing shared reference counting.
Sourcepub fn end_read_epoch(&self)
pub fn end_read_epoch(&self)
Ends a shard-local read epoch and reclaims retired values once the last reader for this shard has exited. Reclamation itself stays on the owner thread and runs lazily from the write path.
Source§impl FlatMap
impl FlatMap
pub fn set<K, V>( &mut self, key: K, value: V, expire_at_ms: Option<u64>, now_ms: u64, )
pub fn set_slice( &mut self, key: &[u8], value: &[u8], expire_at_ms: Option<u64>, now_ms: u64, )
Sourcepub fn set_bytes_hashed(
&mut self,
hash: u64,
key: &[u8],
value: SharedBytes,
expire_at_ms: Option<u64>,
now_ms: u64,
)
pub fn set_bytes_hashed( &mut self, hash: u64, key: &[u8], value: SharedBytes, expire_at_ms: Option<u64>, now_ms: u64, )
Zero-copy SET for the multi-direct hot path: takes value as an
already-owned SharedBytes (typically a split_prefix slice from the
connection read buffer). Avoids the heap allocation that
set_slice_hashed performs to copy value into a new SharedBytes.
Key is copied into a Box<[u8]> so the entry retains a tight key
allocation (keys are small and don’t benefit from sharing).
pub fn set_hashed<K, V>( &mut self, hash: u64, key: K, value: V, expire_at_ms: Option<u64>, now_ms: u64, )
pub fn set_slice_hashed( &mut self, hash: u64, key: &[u8], value: &[u8], expire_at_ms: Option<u64>, now_ms: u64, )
Source§impl FlatMap
impl FlatMap
Sourcepub unsafe fn set_slice_hashed_no_ttl_hot(
&mut self,
hash: u64,
key: &[u8],
value: &[u8],
)
pub unsafe fn set_slice_hashed_no_ttl_hot( &mut self, hash: u64, key: &[u8], value: &[u8], )
§Safety
The caller must guarantee that this map has exclusive ownership of
stored value buffers: no outstanding bytes::Bytes clones and no
borrowed value slices may exist while this runs. The 1-shard FCNP server
satisfies this by using borrowed response encoding and single-threaded
shard ownership.