Skip to main content

Crate kevy_embedded

Crate kevy_embedded 

Source
Expand description

kevy-embedded — kevy without the network.

In-process Redis-compatible key–value store: load + reply directly from your own threads, no TCP, no shards, no reactor. Use this when you want kevy’s data structures + persistence in the same address space as your app — caches, embedded databases, WASM blobs, sidecar tools.

Zero crates.io dependencies: only kevy-store (the keyspace) and kevy-persist (snapshot + AOF). The whole network layer (kevy-rt, kevy-sys, kevy-uring) is intentionally NOT pulled in.

§Quick start

use kevy_embedded::{Store, Config};

let s = Store::open(Config::default())?;
s.set(b"greeting", b"hello")?;
assert_eq!(s.get(b"greeting")?, Some(b"hello".to_vec()));

§With persistence

with_persist(dir) enables AOF auto-append on every write and replays on open — restart-safe out of the box. Snapshot (dump-0.rdb) is loaded first if present; AOF (aof-0.aof) is replayed on top.

use kevy_embedded::{Store, Config};

let s = Store::open(Config::default().with_persist("./data"))?;
s.set(b"counter", b"42")?;
drop(s); // flushes AOF on drop

// Next process: state survives.
let s2 = Store::open(Config::default().with_persist("./data"))?;
assert_eq!(s2.get(b"counter")?, Some(b"42".to_vec()));

§When NOT to use this crate

  • You want a Redis-protocol TCP server → use the kevy crate’s serve instead.
  • You need cross-process concurrency → kevy-embedded is single-process (one mutex). Multi-process needs the network layer.

Structs§

AnnSpec
v2.8 — HNSW declaration (immutable once created; RFC D2).
AtomicAllShards
Context handed to the atomic_all_shards closure body. Methods route to the right shard by hashing the key.
AtomicCtx
Handle passed to the atomic closure body. Methods mirror the equivalent Store ops but operate on the already-held write lock, so reads inside the block see the closure’s own writes.
Change
One mutation delivered by Store::changes_since.
ChangeBatch
A batch of changes plus the cursor to resume from.
Config
Embedded-store config. Build by chaining with_* methods on Config::default.
ExpireStats
What Store::tick_expire saw and did. Surfaced for tests, INFO keyspace, and (eventually) Wave 2 task #4’s crash-safe verifier.
GroupStats
One group’s live statistics.
IndexCursor
Opaque pagination cursor: the last (value, key) served. Encoded by the runtime into the wire cursor; None = start.
IndexStats
Sizing + health counters (IDX.LIST / memory formula).
KevyInfo
Snapshot of a store’s runtime counters, returned by Store::info. A cheap aggregate (one mutex lock); fields mirror the individual accessors.
Pipeline
Builder-style write queue. Returned by Store::pipeline; call fluent methods to enqueue + commit() to apply with batched AOF fsync.
PrefixInfo
Per-prefix keyspace stats from Store::info_prefix.
RewriteStats
Result of an Aof::rewrite_from call. Surfaced by BGREWRITEAOF / INFO persistence.
ScoreBound
A score-range endpoint for ZRANGEBYSCORE/ZCOUNT (inclusive or exclusive). Use value = ±INFINITY for -inf/+inf.
Snapshot
A frozen, consistent point-in-time view of the whole store.
SnapshotEntry
One entry from Snapshot::each_prefix / Snapshot::keys_prefix.
Store
The embedded keyspace.
Subscription
A handle to one subscription — owns the receive end of the bus channel.
ViewLeaf
One leaf: a declared index + the shape it contributes.
WeakStore
Weak handle to a Store — does not keep the underlying keyspace alive.
ZaddFlags
Parsed ZADD condition flags. CH only changes the reply (changed count instead of added count) — callers read ZaddReport::changed when set; the engine behavior is identical.
ZaddReport
Outcome of a flags-aware ZADD.

Enums§

AggBy
Ranking metric for AggSegment::top_groups.
AppendFsync
When to fsync the AOF to disk.
BitOp
Operator for Store::bitop.
EvictionPolicy
Maxmemory eviction policy. Mirror of kevy_config::EvictionPolicy — duplicated here so kevy-store stays a leaf crate (no kevy-config dep).
FeedError
Why a feed read could not be served.
HExpireCond
Condition flags for HEXPIRE (NX/XX/GT/LT; at most one).
IndexKind
Index kind (KIND range|unique).
IndexValType
Declared scalar type of an index (TYPE i64|f64|str).
IndexValue
One indexed scalar. Ordering is total within a type; the catalog guarantees a segment only ever holds one variant.
KevyMetric
A persistence event worth observing. More variants may be added; match non-exhaustively (_ => {}) to stay forward-compatible.
PubsubFrame
One pub/sub event delivered to a Subscription.
StoreError
Operation errors surfaced to the command layer.
TtlReaperMode
How the active TTL reaper runs.
ViewMode
View mode.
ViewTree
The composition tree. Depth ≤ 3, leaves ≤ 4 (declarative caps, enforced at CREATE).
ZAggregate
AGGREGATE mode for inter/union (Redis 6.2; default Sum).

Type Aliases§

HExpireCode
Per-field reply codes for HEXPIRE-family calls (Redis 7.4): -2 key or field missing, 0 condition (NX/XX/GT/LT) not met, 1 deadline set, 2 field deleted (deadline already due).
IndexPage
One page of index hits plus the cursor to resume from.
ViewPage
One page of view members plus the resume cursor.