Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

API Reference

PulseMap provides four map types. Choose based on your concurrency requirements:

TypeThreadsKey/ValueWhen to Use
PulseMapRaw❌ Single[u8] bytesMax perf, raw bytes, FFI (Send + !Sync)
TypedPulseMap<K, V>❌ SingleAny PulseKey/PulseValueType-safe single-threaded
ConcurrentPulseMap<K, V>✅ 1–2TAny PulseKey/PulseValueLow-contention concurrent
ShardedPulseMap<K, V>3+TAny PulseKey/PulseValueHigh-concurrency production

Type Aliases

#![allow(unused)]
fn main() {
/// Raw byte-level map — maximum control
pub type PulseMap = PulseMapRaw;
}

Traits

PulseKey

#![allow(unused)]
fn main() {
pub trait PulseKey: Clone + PartialEq {
    type Bytes: AsRef<[u8]>;
    fn to_bytes(&self) -> Self::Bytes;
    fn from_bytes(bytes: &[u8]) -> Option<Self>;
}
}

Implemented for: String, Vec<u8>, u8, u16, u32, u64, u128, i8, i16, i32, i64, i128

PulseValue

#![allow(unused)]
fn main() {
pub trait PulseValue: Clone {
    type Bytes: AsRef<[u8]>;
    fn to_bytes(&self) -> Self::Bytes;
    fn from_bytes(bytes: &[u8]) -> Option<Self>;
}
}

Implemented for: Same types as PulseKey.

Common Methods (all map types)

MethodDescription
new(num_buckets)Fixed-size map
insert(key, value)Insert or update (uses global TTL)
insert_ttl(key, value, ttl: u64)Insert with per-entry TTL override (v0.6.1+)
get(&key)Lookup — updates eviction priority
peek(&key)Lookup — no priority update (pure read)
remove(&key)Delete, returns bool
contains_key(&key)Existence check
len()Number of live entries
is_empty()Check if empty
capacity()Total slot count
load_factor()len / capacity
eviction_count()Total evicted entries
set_ttl(n: u64)Global TTL in insertion epochs
get_ttl() -> u64Current global TTL
current_epoch() -> u64Total insertions so far

See sub-pages for type-specific APIs and examples.