pub struct EmbeddedStore { /* private fields */ }Expand description
Shared embedded in-memory database.
EmbeddedStore is internally sharded and can be shared across threads. It
offers byte-string key/value methods, Redis object helpers, TTL management,
batch reads and writes, and session-oriented packed transfer APIs.
Implementations§
Source§impl EmbeddedStore
impl EmbeddedStore
Sourcepub fn batch_get(&self, keys: Vec<Bytes>) -> Vec<Option<Bytes>>
pub fn batch_get(&self, keys: Vec<Bytes>) -> Vec<Option<Bytes>>
Returns owned values for keys in request order.
Sourcepub fn batch_get_view(&self, keys: &[Bytes]) -> EmbeddedBatchReadView
pub fn batch_get_view(&self, keys: &[Bytes]) -> EmbeddedBatchReadView
Returns owned views for a generic batch.
This path may touch multiple shards under full_key routing; each hit
is materialized into an owned bytes::Bytes handle.
Sourcepub fn batch_get_session(
&self,
session_prefix: &[u8],
keys: &[Bytes],
) -> Vec<Option<Bytes>>
pub fn batch_get_session( &self, session_prefix: &[u8], keys: &[Bytes], ) -> Vec<Option<Bytes>>
Retrieves a session-scoped batch from a known shard without rediscovering placement from every full chunk key.
pub fn batch_get_session_prehashed( &self, session_prefix: &[u8], keys: &[Bytes], key_hashes: &[u64], ) -> Vec<Option<Bytes>>
Sourcepub fn batch_get_session_routed(
&self,
route: EmbeddedSessionRoute,
keys: &[Bytes],
) -> Vec<Option<Bytes>>
pub fn batch_get_session_routed( &self, route: EmbeddedSessionRoute, keys: &[Bytes], ) -> Vec<Option<Bytes>>
Retrieves a session-scoped batch from a precomputed shard route.
Sourcepub fn batch_get_session_view(
&self,
session_prefix: &[u8],
keys: &[Bytes],
) -> EmbeddedSessionBatchView
pub fn batch_get_session_view( &self, session_prefix: &[u8], keys: &[Bytes], ) -> EmbeddedSessionBatchView
Returns owned views for a session-scoped batch.
Session-slot values are copied into owned handles so the returned view remains valid after later session updates.
pub fn batch_get_session_view_prehashed( &self, session_prefix: &[u8], keys: &[Bytes], key_hashes: &[u64], ) -> EmbeddedSessionBatchView
Sourcepub fn batch_get_session_view_routed(
&self,
route: EmbeddedSessionRoute,
keys: &[Bytes],
) -> EmbeddedSessionBatchView
pub fn batch_get_session_view_routed( &self, route: EmbeddedSessionRoute, keys: &[Bytes], ) -> EmbeddedSessionBatchView
Returns owned views for a session-scoped batch from a precomputed shard route.
Sourcepub fn batch_get_session_view_prehashed_routed(
&self,
route: EmbeddedSessionRoute,
keys: &[Bytes],
key_hashes: &[u64],
) -> EmbeddedSessionBatchView
pub fn batch_get_session_view_prehashed_routed( &self, route: EmbeddedSessionRoute, keys: &[Bytes], key_hashes: &[u64], ) -> EmbeddedSessionBatchView
Returns owned views for a session-scoped batch from a precomputed shard route and precomputed full-key hashes.
Sourcepub fn batch_get_packed(&self, keys: &[Bytes]) -> PackedBatch
pub fn batch_get_packed(&self, keys: &[Bytes]) -> PackedBatch
Retrieves a generic packed batch. This is still copy-out, but it packs all returned bytes into one contiguous buffer to minimize object churn.
Sourcepub fn batch_get_session_packed(
&self,
session_prefix: &[u8],
keys: &[Bytes],
) -> PackedBatch
pub fn batch_get_session_packed( &self, session_prefix: &[u8], keys: &[Bytes], ) -> PackedBatch
Retrieves a session-scoped packed batch from a known shard.
Sourcepub fn batch_get_session_packed_routed(
&self,
route: EmbeddedSessionRoute,
keys: &[Bytes],
) -> PackedBatch
pub fn batch_get_session_packed_routed( &self, route: EmbeddedSessionRoute, keys: &[Bytes], ) -> PackedBatch
Retrieves a session-scoped packed batch from a precomputed shard route.
Source§impl EmbeddedStore
impl EmbeddedStore
Sourcepub fn with_route_mode(
shard_count: usize,
route_mode: EmbeddedRouteMode,
) -> Self
pub fn with_route_mode( shard_count: usize, route_mode: EmbeddedRouteMode, ) -> Self
Creates an embedded store with an explicit routing mode.
Sourcepub fn shard_count(&self) -> usize
pub fn shard_count(&self) -> usize
Returns the number of storage shards.
Sourcepub fn key_snapshot(&self) -> Vec<Bytes> ⓘ
pub fn key_snapshot(&self) -> Vec<Bytes> ⓘ
Returns a sorted snapshot of currently live keys.
Sourcepub fn entry_snapshot(&self) -> Vec<StoredEntry>
pub fn entry_snapshot(&self) -> Vec<StoredEntry>
Returns currently live string entries for persistence or replication.
Redis object values are intentionally excluded; the native replication stream v1 covers byte-string cache mutations.
Sourcepub fn stored_bytes(&self) -> usize
pub fn stored_bytes(&self) -> usize
Returns the approximate number of bytes stored in string values.
Sourcepub fn configure_memory_policy(
&self,
per_shard_memory_limit_bytes: Option<usize>,
eviction_policy: EvictionPolicy,
)
pub fn configure_memory_policy( &self, per_shard_memory_limit_bytes: Option<usize>, eviction_policy: EvictionPolicy, )
Applies a per-shard memory budget and eviction policy.
Sourcepub fn route_mode(&self) -> EmbeddedRouteMode
pub fn route_mode(&self) -> EmbeddedRouteMode
Returns the configured route mode.
Sourcepub fn route_session(&self, session_prefix: &[u8]) -> EmbeddedSessionRoute
pub fn route_session(&self, session_prefix: &[u8]) -> EmbeddedSessionRoute
Computes the route for a session prefix.
Sourcepub fn route_key(&self, key: &[u8]) -> EmbeddedKeyRoute
pub fn route_key(&self, key: &[u8]) -> EmbeddedKeyRoute
Computes the route for a key.
Sourcepub fn prepare_point_key(&self, key: &[u8]) -> PreparedPointKey
pub fn prepare_point_key(&self, key: &[u8]) -> PreparedPointKey
Precomputes route and fingerprint metadata for repeated point lookups.
Source§impl EmbeddedStore
impl EmbeddedStore
Sourcepub fn delete(&self, key: &[u8]) -> bool
pub fn delete(&self, key: &[u8]) -> bool
Deletes a key and returns true when a value or object was removed.
Sourcepub fn ttl_seconds(&self, key: &[u8]) -> i64
pub fn ttl_seconds(&self, key: &[u8]) -> i64
Returns Redis-style TTL in seconds: -2 for missing, -1 for no TTL.
Sourcepub fn pttl_millis(&self, key: &[u8]) -> i64
pub fn pttl_millis(&self, key: &[u8]) -> i64
Returns Redis-style TTL in milliseconds: -2 for missing, -1 for no TTL.
Sourcepub fn persist(&self, key: &[u8]) -> bool
pub fn persist(&self, key: &[u8]) -> bool
Removes the TTL from a key and returns true when a TTL was cleared.
Sourcepub fn expire(&self, key: &[u8], expire_at_ms: u64) -> bool
pub fn expire(&self, key: &[u8], expire_at_ms: u64) -> bool
Sets an absolute expiration timestamp in Unix milliseconds.
Sourcepub fn redis_type(&self, key: &[u8]) -> &'static str
pub fn redis_type(&self, key: &[u8]) -> &'static str
Returns the Redis type name for a key, or "none" when it is missing.
Sourcepub fn object_encoding(&self, key: &[u8]) -> Option<&'static str>
pub fn object_encoding(&self, key: &[u8]) -> Option<&'static str>
Returns the Redis object encoding name for a key when it exists.
Sourcepub fn shard_stats_snapshot(&self) -> Vec<ShardStatsSnapshot>
pub fn shard_stats_snapshot(&self) -> Vec<ShardStatsSnapshot>
Returns per-shard statistics snapshots.
Sourcepub fn stats_snapshot(
&self,
) -> (TierStatsSnapshot, TierStatsSnapshot, TierStatsSnapshot)
pub fn stats_snapshot( &self, ) -> (TierStatsSnapshot, TierStatsSnapshot, TierStatsSnapshot)
Returns aggregate hot, warm, and cold tier statistics.
Sourcepub fn process_maintenance(&self) -> usize
pub fn process_maintenance(&self) -> usize
Runs maintenance on every shard and returns the number of expired entries.
Sourcepub fn restore_entries<I>(&self, entries: I)where
I: IntoIterator<Item = StoredEntry>,
pub fn restore_entries<I>(&self, entries: I)where
I: IntoIterator<Item = StoredEntry>,
Restores persisted entries, skipping records that are already expired.
Source§impl EmbeddedStore
impl EmbeddedStore
Sourcepub fn has_redis_objects(&self) -> bool
pub fn has_redis_objects(&self) -> bool
Returns true when Redis object containers are present.
pub fn get_string_value_into<F>( &self, key: &[u8], write: F, ) -> RedisStringLookup
pub fn hset(&self, key: &[u8], field: &[u8], value: &[u8]) -> RedisObjectResult
pub fn hset_many( &self, key: &[u8], fields: &[(&[u8], &[u8])], ) -> RedisObjectResult
pub fn hget(&self, key: &[u8], field: &[u8]) -> RedisObjectResult
pub fn hexists(&self, key: &[u8], field: &[u8]) -> RedisObjectResult
pub fn hdel(&self, key: &[u8], field: &[u8]) -> RedisObjectResult
pub fn hdel_many(&self, key: &[u8], fields: &[&[u8]]) -> RedisObjectResult
pub fn hlen(&self, key: &[u8]) -> RedisObjectResult
pub fn hmget(&self, key: &[u8], fields: &[&[u8]]) -> RedisObjectResult
pub fn hkeys(&self, key: &[u8]) -> RedisObjectResult
pub fn hvals(&self, key: &[u8]) -> RedisObjectResult
pub fn hgetall(&self, key: &[u8]) -> RedisObjectResult
pub fn hsetnx( &self, key: &[u8], field: &[u8], value: &[u8], ) -> RedisObjectResult
pub fn hincrby(&self, key: &[u8], field: &[u8], delta: i64) -> RedisObjectResult
pub fn hincrbyfloat( &self, key: &[u8], field: &[u8], delta: f64, ) -> RedisObjectResult
pub fn hrandfield( &self, key: &[u8], count: Option<i64>, with_values: bool, ) -> RedisObjectResult
pub fn lpush(&self, key: &[u8], values: &[&[u8]]) -> RedisObjectResult
pub fn rpush(&self, key: &[u8], values: &[&[u8]]) -> RedisObjectResult
pub fn lpushx(&self, key: &[u8], values: &[&[u8]]) -> RedisObjectResult
pub fn rpushx(&self, key: &[u8], values: &[&[u8]]) -> RedisObjectResult
pub fn lpop(&self, key: &[u8]) -> RedisObjectResult
pub fn rpop(&self, key: &[u8]) -> RedisObjectResult
pub fn lpop_count(&self, key: &[u8], count: usize) -> RedisObjectResult
pub fn rpop_count(&self, key: &[u8], count: usize) -> RedisObjectResult
pub fn llen(&self, key: &[u8]) -> RedisObjectResult
pub fn lindex(&self, key: &[u8], index: i64) -> RedisObjectResult
pub fn lrange(&self, key: &[u8], start: i64, stop: i64) -> RedisObjectResult
pub fn lset(&self, key: &[u8], index: i64, value: &[u8]) -> RedisObjectResult
pub fn lrem(&self, key: &[u8], count: i64, value: &[u8]) -> RedisObjectResult
pub fn ltrim(&self, key: &[u8], start: i64, stop: i64) -> RedisObjectResult
pub fn linsert( &self, key: &[u8], before: bool, pivot: &[u8], value: &[u8], ) -> RedisObjectResult
pub fn sadd(&self, key: &[u8], members: &[&[u8]]) -> RedisObjectResult
pub fn srem(&self, key: &[u8], members: &[&[u8]]) -> RedisObjectResult
pub fn sismember(&self, key: &[u8], member: &[u8]) -> RedisObjectResult
pub fn smismember(&self, key: &[u8], members: &[&[u8]]) -> RedisObjectResult
pub fn scard(&self, key: &[u8]) -> RedisObjectResult
pub fn smembers(&self, key: &[u8]) -> RedisObjectResult
pub fn set_members(&self, key: &[u8]) -> Result<Vec<Bytes>, RedisObjectError>
pub fn spop(&self, key: &[u8], count: Option<usize>) -> RedisObjectResult
pub fn srandmember(&self, key: &[u8], count: Option<i64>) -> RedisObjectResult
pub fn zadd(&self, key: &[u8], score: f64, member: &[u8]) -> RedisObjectResult
pub fn zadd_cond( &self, key: &[u8], score: f64, member: &[u8], nx: bool, xx: bool, gt: bool, lt: bool, ch: bool, incr: bool, ) -> RedisObjectResult
pub fn zrem(&self, key: &[u8], member: &[u8]) -> RedisObjectResult
pub fn zrem_many(&self, key: &[u8], members: &[&[u8]]) -> RedisObjectResult
pub fn zscore(&self, key: &[u8], member: &[u8]) -> RedisObjectResult
pub fn zmscore(&self, key: &[u8], members: &[&[u8]]) -> RedisObjectResult
pub fn zincrby( &self, key: &[u8], delta: f64, member: &[u8], ) -> RedisObjectResult
pub fn zcard(&self, key: &[u8]) -> RedisObjectResult
pub fn zrange(&self, key: &[u8], start: i64, stop: i64) -> RedisObjectResult
pub fn zentries( &self, key: &[u8], ) -> Result<Vec<(Bytes, f64)>, RedisObjectError>
pub fn zrank(&self, key: &[u8], member: &[u8], rev: bool) -> RedisObjectResult
pub fn zcount(&self, key: &[u8], min: f64, max: f64) -> RedisObjectResult
pub fn zpop(&self, key: &[u8], count: usize, max: bool) -> RedisObjectResult
pub fn rename_key( &self, source: &[u8], dest: &[u8], nx: bool, ) -> Result<bool, RedisObjectError>
Source§impl EmbeddedStore
impl EmbeddedStore
pub fn bind_shard(&self, shard_id: usize) -> EmbeddedShardHandle<'_>
pub fn into_owned_shards(self) -> Vec<OwnedEmbeddedShard>
pub fn into_owned_workers( self, worker_count: usize, ) -> Vec<OwnedEmbeddedWorkerShards>
Source§impl EmbeddedStore
impl EmbeddedStore
Sourcepub unsafe fn get_blob_string_into_single_threaded(
&self,
key: &[u8],
out: &mut BytesMut,
) -> bool
pub unsafe fn get_blob_string_into_single_threaded( &self, key: &[u8], out: &mut BytesMut, ) -> bool
Single-threaded fused GET + RESP encode. Bypasses the per-shard
RwLock entirely via data_ptr() — saves ~5-10ns per GET in atomic
ops.
§Safety
The caller must guarantee that no other thread is concurrently accessing
any shard of this EmbeddedStore. This is true in the sc=1
multi-direct path where there is exactly one worker thread, but is
unsafe in any other configuration.
Sourcepub unsafe fn get_blob_string_hashed_into_single_threaded(
&self,
key_hash: u64,
key: &[u8],
out: &mut BytesMut,
) -> bool
pub unsafe fn get_blob_string_hashed_into_single_threaded( &self, key_hash: u64, key: &[u8], out: &mut BytesMut, ) -> bool
Prehashed variant of get_blob_string_into_single_threaded for the
RESP fast path, where the key bytes have already been validated.
§Safety
Same contract as get_blob_string_into_single_threaded.
Sourcepub unsafe fn set_single_threaded(
&self,
key: &[u8],
value: &[u8],
ttl_ms: Option<u64>,
)
pub unsafe fn set_single_threaded( &self, key: &[u8], value: &[u8], ttl_ms: Option<u64>, )
Single-threaded SET that bypasses the per-shard RwLock.
§Safety
Same contract as get_blob_string_into_single_threaded.
Sourcepub unsafe fn set_single_threaded_hashed(
&self,
key_hash: u64,
key: &[u8],
value: &[u8],
ttl_ms: Option<u64>,
)
pub unsafe fn set_single_threaded_hashed( &self, key_hash: u64, key: &[u8], value: &[u8], ttl_ms: Option<u64>, )
Prehashed variant of set_single_threaded for canonical RESP SET.
§Safety
Same contract as set_single_threaded.
Sourcepub unsafe fn set_single_threaded_hashed_tagged_no_ttl_hot(
&self,
key_hash: u64,
key_tag: u64,
key: &[u8],
value: &[u8],
)
pub unsafe fn set_single_threaded_hashed_tagged_no_ttl_hot( &self, key_hash: u64, key_tag: u64, key: &[u8], value: &[u8], )
FCNP single-shard SET path with both hashes supplied by the client.
§Safety
Same contract as set_single_threaded_hashed; additionally, key_tag
must equal hash_key_tag_from_hash(key_hash).
Sourcepub fn get_blob_string_into(&self, key: &[u8], out: &mut BytesMut) -> bool
pub fn get_blob_string_into(&self, key: &[u8], out: &mut BytesMut) -> bool
Fused GET + RESP-blob-string-encode for the multi-direct hot path.
Writes $<len>\r\n<value>\r\n directly into out under the shard read
lock, eliminating the Vec<u8> intermediate that the generic get
path’s .to_vec() allocates. Returns true if the key existed.
Sourcepub fn get_blob_string_hashed_into(
&self,
key_hash: u64,
key: &[u8],
out: &mut BytesMut,
) -> bool
pub fn get_blob_string_hashed_into( &self, key_hash: u64, key: &[u8], out: &mut BytesMut, ) -> bool
Prehashed fused GET + RESP encode. Used by the RESP fast path after it validates the key bytes and computes the hash once.
Sourcepub fn set_slice_prehashed(
&self,
key_hash: u64,
key: &[u8],
value: &[u8],
ttl_ms: Option<u64>,
)
pub fn set_slice_prehashed( &self, key_hash: u64, key: &[u8], value: &[u8], ttl_ms: Option<u64>, )
Prehashed slice SET for the RESP fast path. Avoids rehashing in storage after parsing has already identified the key.
Sourcepub fn get_value_bytes(&self, key: &[u8]) -> Option<Bytes>
pub fn get_value_bytes(&self, key: &[u8]) -> Option<Bytes>
Zero-copy GET for the multi-direct hot path. Returns the stored
bytes::Bytes directly (refcount-only clone of FlatEntry.value),
avoiding the Vec<u8> allocation that get performs to materialize
Bytes = Vec<u8> for the public API.
Sourcepub fn get_value_bytes_route_hashed(
&self,
route_hash: u64,
key: &[u8],
) -> Option<Bytes>
pub fn get_value_bytes_route_hashed( &self, route_hash: u64, key: &[u8], ) -> Option<Bytes>
FastCodec GET path. The wire header carries a route hash so the server can usually skip hashing the key again. For session-prefixed keys in session route mode, the route hash is intentionally the session prefix hash, not the full key hash, so we fall back to the generic lookup.
Sourcepub fn with_value_bytes_route_hashed<F>(
&self,
route_hash: u64,
key: &[u8],
write: F,
) -> bool
pub fn with_value_bytes_route_hashed<F>( &self, route_hash: u64, key: &[u8], write: F, ) -> bool
FastCodec GET path that calls write while the value reference is
still protected by the shard read lock. This avoids the refcount bump
and drop from returning bytes::Bytes on the native GET hot path.
Route-hashed GET path that exposes the stored Bytes object while the
shard lock is held. Callers can clone the Bytes handle for large
zero-copy writes, while small responses can still copy from the borrowed
value without an extra refcount bump.
Full-key FCNP GET path for clients that provide the key hash, key tag, and key length but omit the key bytes. This is safe for concurrent multi-shard access because the value is exposed only while the shard read lock is held.
Sourcepub fn getex_value_bytes_route_hashed(
&self,
route_hash: Option<u64>,
key: &[u8],
ttl_ms: u64,
) -> Option<Bytes>
pub fn getex_value_bytes_route_hashed( &self, route_hash: Option<u64>, key: &[u8], ttl_ms: u64, ) -> Option<Bytes>
Native GETEX path for v2. Returns the value and applies the TTL while holding the target shard write lock.
Sourcepub fn with_getex_value_bytes_route_hashed<F>(
&self,
route_hash: Option<u64>,
key: &[u8],
ttl_ms: u64,
write: F,
) -> bool
pub fn with_getex_value_bytes_route_hashed<F>( &self, route_hash: Option<u64>, key: &[u8], ttl_ms: u64, write: F, ) -> bool
Native GETEX path that writes the value while it is borrowed from the
shard. This avoids the Bytes clone/drop pair in the returning GETEX
helper.
Sourcepub unsafe fn get_value_bytes_route_hashed_single_threaded(
&self,
route_hash: u64,
key: &[u8],
) -> Option<Bytes>
pub unsafe fn get_value_bytes_route_hashed_single_threaded( &self, route_hash: u64, key: &[u8], ) -> Option<Bytes>
Single-threaded FastCodec GET path. Avoids shard RwLock atomics in
the same direct sc=1 setup as the RESP fused single-threaded path.
§Safety
The caller must guarantee that no other thread is concurrently accessing
any shard of this EmbeddedStore.
Sourcepub unsafe fn with_value_bytes_route_hashed_single_threaded<F>(
&self,
route_hash: u64,
key: &[u8],
write: F,
) -> bool
pub unsafe fn with_value_bytes_route_hashed_single_threaded<F>( &self, route_hash: u64, key: &[u8], write: F, ) -> bool
Single-threaded variant of with_value_bytes_route_hashed.
§Safety
The caller must guarantee that no other thread is concurrently accessing
any shard of this EmbeddedStore.
Single-threaded FCNP GET helper that exposes the stored Bytes object
to the caller. This lets the network path clone only the refcount for
large zero-copy writes, while keeping small values on the borrowed
inline-copy path.
§Safety
The caller must guarantee that no other thread is concurrently accessing
any shard of this EmbeddedStore.
1-shard full-key FCNP GET helper for the hottest native path. This skips route-mode, shard-count, and session-slot checks that the general routed helper must keep.
§Safety
The caller must guarantee that this store has exactly one shard, uses
EmbeddedRouteMode::FullKey, and no other thread is concurrently
accessing the shard.
1-shard full-key FCNP GET helper that returns the stored Bytes
reference directly. This keeps the hottest native GET path out of the
closure-based wrapper used by the general routed path.
§Safety
The caller must guarantee that this store has exactly one shard, uses
EmbeddedRouteMode::FullKey, and no other thread is concurrently
accessing the shard.
1-shard full-key FCNP GET helper for clients that supply both the key hash and key tag. The native protocol treats that tuple plus key length as the lookup identity, avoiding a key-byte compare in the hottest path.
§Safety
The caller must guarantee that this store has exactly one shard, uses
EmbeddedRouteMode::FullKey, and no other thread is concurrently
accessing the shard. key_tag must be the tag for the key bytes that
produced key_hash.
Safe shard-owned full-key GET helper for direct-shard server workers.
This keeps safe builds on the normal shard RwLock, but avoids the
generic route/session fallback after the FCNP frame has already proven
that the request belongs to shard_id.
Shard-owned full-key FCNP GET helper for direct-shard server workers.
This is the multi-shard counterpart to
get_shared_value_bytes_full_key_tagged_single_threaded: one server
worker owns shard_id, the client supplies the full-key hash and tag,
and the lookup can skip both the shard lock and the key-byte compare.
Returns None when the hot path is not valid, such as TTL-bearing
shards, invalid shard ids, non-full-key routing, or a route mismatch.
Otherwise returns Some(true) for a hit and Some(false) for a miss.
§Safety
The caller must guarantee that no other thread is concurrently accessing
shard_id, that key_hash routes to shard_id, and that key_tag
matches the key bytes that produced key_hash.
Sourcepub unsafe fn with_session_value_slice_owned_shard_no_ttl_prevalidated<F>(
&self,
shard_id: usize,
session_hash: u64,
key_hash: u64,
session_prefix: &[u8],
key: &[u8],
write: F,
) -> Option<bool>
pub unsafe fn with_session_value_slice_owned_shard_no_ttl_prevalidated<F>( &self, shard_id: usize, session_hash: u64, key_hash: u64, session_prefix: &[u8], key: &[u8], write: F, ) -> Option<bool>
Shard-owned session-prefix GET helper for direct-shard server workers.
Session slabs store borrowed value slices instead of Bytes, so this
helper writes through a slice callback and avoids the generic fallback’s
Bytes::copy_from_slice materialization. The caller has already
validated that session_prefix routes to shard_id; this helper only
checks storage preconditions and performs the lookup.
§Safety
When built with the unsafe feature, the caller must guarantee no other
thread is concurrently accessing shard_id. Safe builds keep the shard
read lock and therefore only require the route metadata to be valid.
Sourcepub fn set_session_slice_hashed_owned_shard_no_ttl_prevalidated(
&self,
shard_id: usize,
session_hash: u64,
key_hash: u64,
session_prefix: &[u8],
key: &[u8],
value: &[u8],
) -> bool
pub fn set_session_slice_hashed_owned_shard_no_ttl_prevalidated( &self, shard_id: usize, session_hash: u64, key_hash: u64, session_prefix: &[u8], key: &[u8], value: &[u8], ) -> bool
Safe shard-owned no-TTL session SET helper for direct-shard workers.
The caller has already validated that session_prefix routes to
shard_id; this helper only enforces storage preconditions and performs
the session-slab write.
Sourcepub unsafe fn set_session_slice_hashed_owned_shard_no_ttl_hot_prevalidated(
&self,
shard_id: usize,
session_hash: u64,
key_hash: u64,
session_prefix: &[u8],
key: &[u8],
value: &[u8],
) -> bool
pub unsafe fn set_session_slice_hashed_owned_shard_no_ttl_hot_prevalidated( &self, shard_id: usize, session_hash: u64, key_hash: u64, session_prefix: &[u8], key: &[u8], value: &[u8], ) -> bool
Shard-owned no-TTL session SET helper for direct-shard workers.
§Safety
The caller must guarantee exclusive access to shard_id and that the
session prefix routes to that shard.
Sourcepub fn set_slice_hashed_tagged_owned_shard_no_ttl(
&self,
shard_id: usize,
key_hash: u64,
key_tag: u64,
key: &[u8],
value: &[u8],
) -> bool
pub fn set_slice_hashed_tagged_owned_shard_no_ttl( &self, shard_id: usize, key_hash: u64, key_tag: u64, key: &[u8], value: &[u8], ) -> bool
Safe shard-owned no-TTL SET helper for direct-shard server workers.
The helper still takes the shard write lock. It only specializes the
routing and no-TTL storage path when the worker-owned shard checks have
already succeeded; unsupported cases return false so callers can
preserve the generic fallback behavior.
Sourcepub unsafe fn set_slice_hashed_tagged_owned_shard_no_ttl_hot(
&self,
shard_id: usize,
key_hash: u64,
key_tag: u64,
key: &[u8],
value: &[u8],
) -> bool
pub unsafe fn set_slice_hashed_tagged_owned_shard_no_ttl_hot( &self, shard_id: usize, key_hash: u64, key_tag: u64, key: &[u8], value: &[u8], ) -> bool
Shard-owned full-key FCNP SET helper for direct-shard server workers.
§Safety
The caller must guarantee exclusive access to shard_id, that
key_hash routes to shard_id, and that key_tag matches key.
Sourcepub unsafe fn getex_value_bytes_route_hashed_single_threaded(
&self,
route_hash: Option<u64>,
key: &[u8],
ttl_ms: u64,
) -> Option<Bytes>
pub unsafe fn getex_value_bytes_route_hashed_single_threaded( &self, route_hash: Option<u64>, key: &[u8], ttl_ms: u64, ) -> Option<Bytes>
Single-threaded native GETEX path.
§Safety
The caller must guarantee that no other thread is concurrently accessing
any shard of this EmbeddedStore.
Sourcepub unsafe fn with_getex_value_bytes_route_hashed_single_threaded<F>(
&self,
route_hash: Option<u64>,
key: &[u8],
ttl_ms: u64,
write: F,
) -> bool
pub unsafe fn with_getex_value_bytes_route_hashed_single_threaded<F>( &self, route_hash: Option<u64>, key: &[u8], ttl_ms: u64, write: F, ) -> bool
Single-threaded borrowed native GETEX path.
§Safety
The caller must guarantee that no other thread is concurrently accessing
any shard of this EmbeddedStore.
Sourcepub fn get_view(&self, key: &[u8]) -> EmbeddedReadView
pub fn get_view(&self, key: &[u8]) -> EmbeddedReadView
Returns an owned read view for one key.
The returned view owns the bytes it exposes, so callers can safely pass the metadata through FFI or buffer-style APIs without tying it to the store’s lifetime.
pub fn get_prepared_view_no_ttl( &self, prepared: &PreparedPointKey, ) -> EmbeddedReadView
pub fn get_view_routed_no_ttl( &self, route: EmbeddedKeyRoute, key: &[u8], ) -> EmbeddedReadView
pub fn get_view_routed( &self, route: EmbeddedKeyRoute, key: &[u8], now_ms: u64, ) -> EmbeddedReadView
Source§impl EmbeddedStore
impl EmbeddedStore
Sourcepub fn set<K, V>(&self, key: K, value: V, ttl_ms: Option<u64>)
pub fn set<K, V>(&self, key: K, value: V, ttl_ms: Option<u64>)
Inserts or replaces a byte-string value.
ttl_ms is a relative TTL in milliseconds. Passing None creates a
persistent value.
Sourcepub fn set_value_bytes(&self, key: &[u8], value: Bytes, ttl_ms: Option<u64>)
pub fn set_value_bytes(&self, key: &[u8], value: Bytes, ttl_ms: Option<u64>)
Zero-copy SET for the multi-direct hot path. Takes key as a slice
(copied into the entry’s small Box<[u8]>) and value as an
already-owned bytes::Bytes (typically a slice of the connection read
buffer obtained via HandoffBuffer::split_prefix). Skips the
value.to_vec() allocation that the generic set performs.
pub fn set_routed_no_ttl<K, V>(&self, route: EmbeddedKeyRoute, key: K, value: V)
pub fn set_slice_routed_no_ttl( &self, route: EmbeddedKeyRoute, key: &[u8], value: &[u8], )
pub fn batch_set_session_slices_routed_no_ttl<I, K, V>( &self, route: EmbeddedSessionRoute, items: I, )
pub fn batch_set_session_slices_no_ttl<I, K, V>( &self, session_prefix: &[u8], items: I, )
pub fn batch_set_session_owned_no_ttl( &self, session_prefix: Bytes, items: Vec<(Bytes, Bytes)>, )
pub fn batch_set_session_packed_no_ttl(&self, packed: PackedSessionWrite)
pub fn set_routed<K, V>( &self, route: EmbeddedKeyRoute, key: K, value: V, ttl_ms: Option<u64>, )
Source§impl EmbeddedStore
impl EmbeddedStore
Sourcepub fn into_local_store_bootstrap(
self,
worker_count: usize,
) -> WorkerLocalEmbeddedStoreBootstrap
pub fn into_local_store_bootstrap( self, worker_count: usize, ) -> WorkerLocalEmbeddedStoreBootstrap
Partition this store into worker-local embedded stores.
Sourcepub fn into_local_stores(
self,
worker_count: usize,
) -> Vec<WorkerLocalEmbeddedStore>
pub fn into_local_stores( self, worker_count: usize, ) -> Vec<WorkerLocalEmbeddedStore>
Partition this store and return the worker-local stores directly.