Expand description
edgestore-tier — Tiered storage for EdgeStore.
Wraps a local Engine with a RemoteStore (S3, filesystem, etc.) to provide
transparent read-through from local SSD to cold archive.
§Usage
use edgestore::{EdgestoreConfig, Engine};
use edgestore_repl::S3RemoteStore;
use edgestore_tier::TieredEngine;
let local = Engine::open(EdgestoreConfig::new("/tmp/db")).unwrap();
let remote = S3RemoteStore::new("my-bucket", Some("mydb/"), None).unwrap();
let mut tiered = TieredEngine::new(local, Box::new(remote));
// write goes to local
tiered.put(b"users", b"alice", b"data").unwrap();
// read tries local first; on miss checks remote segments
let val = tiered.get(b"users", b"alice").unwrap();§How it works
- Writes go to the local
Engineonly. The hot path is unchanged. - Archiving (
archive_segments) uploads local segments to the remote store and records them in an archived-segment list. get()tries local first. On miss, scans archived segments by key bounds, downloads the matching segment, imports it viaEngine::import_segment(LWW merge), then retries.range()andprefix()merge local results with any archived segments whose key bounds overlap the query range. Archived segments are downloaded ephemerally (no local import, no disk growth) and merged in-memory viaImmutableEngine. Local data wins for any key present in both local and archived segments.- Text-index stripping (
with_text_stripping(true)) removes embedded BM25 index records from local segment copies after successful archival, reclaiming disk space without touching the remote copy. - No background tasks. Everything is synchronous and caller-driven. The application decides when to archive, how much to keep local, and whether to prefetch.
§Monitor-and-archive pattern
use edgestore::{EdgestoreConfig, Engine};
use edgestore_repl::FilesystemRemoteStore;
use edgestore_tier::TieredEngine;
let local = Engine::open(EdgestoreConfig::new("/var/db/hot")).unwrap();
let remote = FilesystemRemoteStore::new("/mnt/cold".into()).unwrap();
let mut tiered = TieredEngine::new(local, Box::new(remote))
.with_text_stripping(true)
.with_segment_cache_bytes(32 * 1024 * 1024);
loop {
let metas = tiered.local().list_segment_metas();
if metas.len() > 8 {
let to_archive = &metas[..metas.len() - 4];
tiered.archive_segments(to_archive).unwrap();
}
}Structs§
- Archived
Segment - Metadata for a segment that lives in remote storage.
- Tiered
Engine - Tiered engine: local hot cache + remote cold archive.