Wind-KVStore is a lightweight, efficient, and persistent key-value storage engine implemented in Rust. The project combines a high-performance storage engine with a user-friendly command-line interface and net server, making it suitable for scenarios requiring local persistent storage.
- π Persistent Storage - Data securely written to disk with crash recovery support
- π Write-Ahead Log (WAL) - Ensures operation atomicity and durability
- β‘ Memory-Mapped Files - Provides high-performance file access
- ποΈ LRU Caching - Automatically manages hot data caching
- π’ Paged Storage - Supports overflow pages for large value data
- β»οΈ Free Page Management - Efficient disk space reuse
- ποΈ Database Compression - Optimizes storage space utilization
- >_ Interactive Shell - Offers intuitive command-line interface
- π₯οΈ Server - Provides clean server interface with built-in session management
- Rust toolchain (Installation Guide)
# Clone repository
git clone https://github.com/starwindv/wind-kvstore
cd wind-kvstore
# Build project
cargo build --release
# Run interactive Shell
cargo run --bin wkshell --release
# Run server
cargo run --bin wkserver --releaseAdd to your Cargo.toml:
[dependencies]
wind-kvstore = { git = "https://github.com/starwindv/wind-kvstore" }use wind_kvstore::KVStore;
use anyhow::Result;
fn main() -> Result<()> {
// Open database
let mut store = KVStore::open("app_data.db", Some("MyAppDB"))?;
// Store data
store.put(b"username", b"alice")?;
// Retrieve data
if let Some(value) = store.get(b"username")? {
println!("Username: {}", String::from_utf8_lossy(&value));
}
// Delete data
store.delete(b"username")?;
// Set database identifier
store.set_identifier("UserDatabase")?;
// Compact database
store.compact()?;
// Close database
store.close()?;
Ok(())
}impl KVStore {
/// Open or create database
pub fn open<P: AsRef<Path>>(
path: P,
db_identifier: Option<&str>
) -> Result<Self>{}
/// Store key-value pair
pub fn put(&mut self, key: &[u8], value: &[u8]) -> Result<()>{}
/// Retrieve value
pub fn get(&mut self, key: &[u8]) -> Result<Option<Vec<u8>>>{}
/// Delete key-value
pub fn delete(&mut self, key: &[u8]) -> Result<()>{}
/// Compact database
pub fn compact(&mut self) -> Result<()>{}
/// Get database identifier
pub fn get_identifier(&self) -> &str{}
/// Set database identifier
pub fn set_identifier(&mut self, identifier: &str) -> Result<()>{}
/// Close database
pub fn close(mut self) -> Result<()>{}
}βββ build.rs # Build script (records compilation time)
βββ Cargo.toml # Project configuration and dependency management
βββ doc/ # Another documentation(Chinese and English)
βββ README.md # Project documentation (English)
βββ README_CN.md # Project documentation (Chinese)
βββ LICENSE # MIT
βββ sdk
β βββ python/ # Wind-KVStore server's sdk for python
β βββ test/ # Test sdk
βββ GUI
β βββ src/ # Wind KVStore's visualize interface
β βββ LICENSE # GPLv3
βββ src
βββ config.rs # Server configuration loader
βββ kvstore.rs # Core KV storage engine implementation
βββ server.rs # Server main logic
βββ server_main.rs # Server entry point
βββ shell.rs # Interactive shell main logic
βββ shell_main.rs # Interactive shell entry point
βββ utils.rs # Utility functions
+-----------------------+
| File Header (128B) |
+-----------------------+
| Page Header (16B) |
+-----------------------+
| Key-Value Data |
+-----------------------+
| Overflow Page Ptr |
+-----------------------+
| ... |
+-----------------------+
-
Paged Storage
- Fixed-size pages (default 1KB)
- Overflow page support for large values
- Free page linked list management
-
Write-Ahead Log
- Operation logging
- Automatic crash recovery
- Atomic operation guarantee
-
Cache Management
- LRU caching strategy
- Automatic hot data management
- Default 100KB cache size
-
Space Optimization
- Automatic free page recycling
- Online database compression
- Efficient storage layout
We welcome all forms of contributions! When contributing, we recommend:
- Updating relevant documentation
- Submitting clear PR descriptions
- Not worrying about communication language - we accept both English and Chinese descriptions. If you're not comfortable with these languages, feel free to use your preferred language
This project is licensed under the MIT License