pub struct Snapshot { /* private fields */ }Expand description
A frozen, consistent point-in-time view of the whole store.
Implementations§
Source§impl Snapshot
impl Snapshot
Sourcepub fn reconcile(
&self,
rows_prefix: &[u8],
derived_prefixes: &[&[u8]],
derived: impl FnMut(&[u8], &Value) -> Vec<Vec<u8>>,
) -> ReconcileReport
pub fn reconcile( &self, rows_prefix: &[u8], derived_prefixes: &[&[u8]], derived: impl FnMut(&[u8], &Value) -> Vec<Vec<u8>>, ) -> ReconcileReport
Rebuild every derived key from the rows under rows_prefix and
diff it against what actually exists under derived_prefixes.
derived is the function from a row to the keys it implies —
the same one the write path uses (cookbook §21). Whatever it
returns for a row is what that row is entitled to; anything else
under derived_prefixes is an orphan.
derived_prefixes must cover everywhere derived keys live. A
derived key outside them is invisible to both directions of the
diff: it cannot be reported missing (nothing looks for it) and
it cannot be reported orphaned (nothing enumerates it). This is
the one way to get a falsely clean report, so the prefixes are a
required argument rather than an option with a default.
The snapshot is frozen, so a clean system reports clean no matter what writers are doing.
let report = store.snapshot().reconcile(
b"user:",
&[b"email:", b"dept:"],
|key, _row| vec![[b"email:".as_slice(), key].concat()],
);
assert!(report.is_clean());Source§impl Snapshot
impl Snapshot
Sourcepub fn each_prefix<F: FnMut(&[u8], &Value, Option<u64>)>(
&self,
prefix: &[u8],
f: F,
)
pub fn each_prefix<F: FnMut(&[u8], &Value, Option<u64>)>( &self, prefix: &[u8], f: F, )
Visit every entry under prefix as (key, value, ttl_ms) —
the raw kevy_store::Value borrow, for callers that want the
typed payload without copies.
Sourcepub fn keys_prefix(&self, prefix: &[u8]) -> Vec<SnapshotEntry>
pub fn keys_prefix(&self, prefix: &[u8]) -> Vec<SnapshotEntry>
Collect the keys (+ TTLs) under prefix, unordered across
shards.