Skip to main content

kevy_embedded/
lib.rs

1//! kevy-embedded — kevy without the network.
2//!
3//! In-process Redis-compatible key–value store: load + reply directly from
4//! your own threads, no TCP, no shards, no reactor. Use this when you want
5//! kevy's data structures + persistence in the same address space as your
6//! app — caches, embedded databases, WASM blobs, sidecar tools.
7//!
8//! Zero crates.io dependencies: only `kevy-store` (the keyspace)
9//! and `kevy-persist` (snapshot + AOF). The whole network layer
10//! (`kevy-rt`, `kevy-sys`, `kevy-uring`) is intentionally NOT pulled in.
11//!
12//! # Quick start
13//!
14//! ```
15//! use kevy_embedded::{Store, Config};
16//!
17//! # fn main() -> std::io::Result<()> {
18//! let s = Store::open(Config::default())?;
19//! s.set(b"greeting", b"hello")?;
20//! assert_eq!(s.get(b"greeting")?, Some(b"hello".to_vec()));
21//! # Ok(())
22//! # }
23//! ```
24//!
25//! # With persistence
26//!
27//! `with_persist(dir)` enables AOF auto-append on every write and replays
28//! on `open` — restart-safe out of the box. Snapshot (`dump-0.rdb`) is
29//! loaded first if present; AOF (`aof-0.aof`) is replayed on top.
30//!
31//! ```no_run
32//! use kevy_embedded::{Store, Config};
33//!
34//! # fn main() -> std::io::Result<()> {
35//! let s = Store::open(Config::default().with_persist("./data"))?;
36//! s.set(b"counter", b"42")?;
37//! drop(s); // flushes AOF on drop
38//!
39//! // Next process: state survives.
40//! let s2 = Store::open(Config::default().with_persist("./data"))?;
41//! assert_eq!(s2.get(b"counter")?, Some(b"42".to_vec()));
42//! # Ok(())
43//! # }
44//! ```
45//!
46//! # When NOT to use this crate
47//!
48//! - You want a Redis-protocol TCP server → use the `kevy` crate's
49//!   [`serve`](https://docs.rs/kevy/latest/kevy/fn.serve.html) instead.
50//! - You need cross-process concurrency → kevy-embedded is single-process
51//!   (one mutex). Multi-process needs the network layer.
52#![forbid(unsafe_code)]
53
54mod config;
55mod info;
56mod ops;
57mod pubsub;
58mod pubsub_bus;
59mod replay;
60mod store;
61
62pub use config::{AppendFsync, Config, EvictionPolicy, TtlReaperMode};
63pub use info::KevyInfo;
64pub use kevy_persist::RewriteStats;
65pub use kevy_store::{ExpireStats, StoreError};
66pub use pubsub::{PubsubFrame, Subscription};
67pub use store::{Store, WeakStore};