An embedded, persistent key-value store written in Rust.
Principles
- High write throughput - Optimized for write-heavy workloads
- Durability - Write-ahead logging (WAL) ensures data persistence
Installation
Add to your Cargo.toml:
[]
= "0.1"
Or install the binaries from GitHub Releases.
Usage
Library Usage (snaildb)
Basic Operations
use SnailDb;
use Result;
Custom Flush Threshold
use SnailDb;
let mut db = open?
.with_flush_threshold; // Flush memtable after 256 MiB
Working with Strings
let mut db = open?;
// Store string values
db.put?;
// Retrieve as string
if let Some = db.get?
Error Handling
use SnailDb;
use ;
Examples
See the examples directory for more detailed usage examples.
Configuration
Flush Threshold
The flush threshold determines when the in-memory memtable is flushed to disk as an SSTable. Default is 250 MiB.
let mut db = open?
.with_flush_threshold; // Custom threshold
Architecture
snailDB uses an LSM-tree (Log-Structured Merge-tree) architecture:
- Memtable - In-memory structure for recent writes
- WAL (Write-Ahead Log) - Ensures durability by logging all writes
- SSTables - Immutable on-disk structures created from flushed memtables
Roadmap
Current work in progress:
- Durable async WAL - Group commit and crash recovery improvements
- Compaction - Background compaction to manage SSTable growth
- Iterators & scans - Efficient range queries and prefix scans
- Performance optimizations - Block caching and metrics
License
Licensed under the Apache License, Version 2.0. See LICENSE file for details.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.