Welcome to SmartStashDB, a blazing-fast, Go-powered key-value store built from scratch using LSM-Tree, Skip-List, and Write-Ahead Logging (WAL). Designed for high throughput and low latency, SmartStashDB is perfect for applications demanding scalable, reliable, and efficient data storage.
- High Performance: Optimized for low-latency reads and writes, leveraging LSM-Tree and Skip-List for efficient data organization.
- Durability: Write-Ahead Logging ensures no data is lost, even in the face of crashes.
- Scalability: LSM-Tree architecture supports massive datasets with seamless compaction.
- Memory Efficiency: Skip-List provides fast in-memory indexing with minimal overhead.
- Simple API: Intuitive key-value operations for easy integration.
- Go-Powered: Written in Go for concurrency, simplicity, and cross-platform support.
SmartStashDB combines cutting-edge data structures and techniques to deliver top-tier performance:
- LSM-Tree: Log-Structured Merge-Tree for write-heavy workloads, with background compaction to keep reads fast.
- Skip-List: Probabilistic data structure for in-memory indexing, enabling O(log n) lookups.
- WAL: Write-Ahead Logging for crash recovery and data durability.
- Compaction: Periodic merging of SSTables to optimize storage and query performance.
[Client] --> [API: Get/Put/Delete] --> [MemTable (Skip-List)]
|
v
[WAL (Disk)]
|
v
[SSTables (LSM-Tree)]
- Go: Version 1.18 or higher
- A passion for high-performance systems! 😎
- Clone the repository:
git clone https://github.com/johnsoy/SmartStashDB.git cd SmartStashDB
- Install dependencies:
go mod tidy
- Build and run:
go build ./SmartStashDB
package main
import (
"fmt"
"github.com/johnsoy/SmartStashDB"
)
func main() {
// Initialize SmartStashDB
kv, err := SmartStashDB.NewSmartStashDB("./data")
if err != nil {
panic(err)
}
defer kv.Close()
// Put key-value pair
kv.Put([]byte("key1"), []byte("value1"))
// Get value
value, err := kv.Get([]byte("key1"))
if err != nil {
panic(err)
}
fmt.Printf("Key: key1, Value: %s\n", value)
// Delete key
kv.Delete([]byte("key1"))
}
SmartStashDB is designed for speed and scalability. Preliminary benchmarks (on a standard laptop with SSD):
- Write Throughput: ~500,000 ops/sec
- Read Throughput: ~600,000 ops/sec
- Latency: < 1ms for 99th percentile reads/writes
Run benchmarks yourself:
go test -bench=.
Customize SmartStashDB via the config.yaml
file:
data_dir: "./data" # Storage directory
memtable_size: 1048576 # Max MemTable size (bytes)
compaction_interval: 60 # Compaction interval (seconds)
wal_flush_interval: 10 # WAL flush interval (seconds)
Load config programmatically:
kv, err := SmartStashDB.NewSmartStashDBWithConfig("config.yaml")
Contributions are welcome! Whether it's bug fixes, new features, or documentation improvements, here's how to get started:
- Fork the repository.
- Create a feature branch:
git checkout -b feature/awesome-feature
. - Commit your changes:
git commit -m "Add awesome feature"
. - Push to the branch:
git push origin feature/awesome-feature
. - Open a Pull Request.
Please read our CONTRIBUTING.md for more details.
SmartStashDB is licensed under the MIT License. Feel free to use, modify, and distribute it as you see fit!
- GitHub: Johnsoy
- Email: [15520754767@163.com]
Star ⭐ this repo if you find SmartStashDB awesome, and let's build the fastest KV store together! 🚀