pub struct ReactiveMap<K, V>{
pub node_id: NodeId,
/* private fields */
}Expand description
Reactive key-value map.
Emits Vec<(K, V)> snapshots via a Core state node on every mutation.
(Vec of pairs rather than HashMap for serialization stability.)
Fields§
§node_id: NodeIdImplementations§
Source§impl<K, V> ReactiveMap<K, V>
impl<K, V> ReactiveMap<K, V>
Sourcepub fn new(
core: &Core,
intern: InternFn<Vec<(K, V)>>,
opts: ReactiveMapOptions<K, V>,
) -> Result<Self, MapConfigError>
pub fn new( core: &Core, intern: InternFn<Vec<(K, V)>>, opts: ReactiveMapOptions<K, V>, ) -> Result<Self, MapConfigError>
Create a new reactive map.
§Errors
Returns MapConfigError if both max_size (LRU) and retention are set.
pub fn size(&self) -> usize
Sourcepub fn has(&self, key: &K) -> bool
pub fn has(&self, key: &K) -> bool
Check if key exists. Expired keys are pruned (observable side-effect). LRU touch: live key is marked as most-recently-used (no emission).
Sourcepub fn get(&self, key: &K) -> Option<V>
pub fn get(&self, key: &K) -> Option<V>
Get value by key. Expired keys return None (observable side-effect).
LRU touch: live key is marked as most-recently-used (no emission).
pub fn set(&self, key: K, value: V)
Sourcepub fn set_with_ttl(&self, key: K, value: V, ttl: Option<f64>)
pub fn set_with_ttl(&self, key: K, value: V, ttl: Option<f64>)
Set a key with an optional per-call TTL override (seconds).
§Panics
Panics if ttl is Some with a non-positive or non-finite value.
pub fn set_many(&self, entries: Vec<(K, V)>)
Sourcepub fn set_many_with_ttl(&self, entries: Vec<(K, V)>, ttl: Option<f64>)
pub fn set_many_with_ttl(&self, entries: Vec<(K, V)>, ttl: Option<f64>)
Batch set with optional per-call TTL override (seconds).
§Panics
Panics if ttl is Some with a non-positive or non-finite value.
pub fn delete(&self, key: &K)
pub fn delete_many(&self, keys: &[K])
pub fn clear(&self)
Sourcepub fn prune_expired(&self) -> usize
pub fn prune_expired(&self) -> usize
Explicitly prune all expired keys. Returns the number of keys removed.