Ferrislog: A server based kvs
A persistent, log-structured key-value store implemented in Rust with a friendly CLI interface. Designed for reliability and simplicity.
Features
- Network Client Support: Operations can be called from a device to a server
- Core Operations: Set, get, and remove key-value pairs with easy commands
- Persistence: All operations are logged as JSON to survive program restarts
- Automatic Log Compaction: Automatic compaction when log size exceeds threshold
- Snapshots: Create and load snapshots for backup and recovery
- Command Line Interface: Built with
clapfor intuitive command parsing - Automatic Separation: If the server address isn't given, the log will be saved in the local device
Installation
# Clone the repository
# Build with Cargo
# Install globally
Usage
Server
# Setup the server in 127.0.0.1:8080
# Setup the server in 127.0.0.1:8080 with the KvEngine
# Setup the server in 127.0.0.1:8080 with Sled
Client
# Set a key-value pair
# Get the value for a key
# Output: ferris
# Remove a key
# Try to get a non-existent key
# Output: Key not found
Implementation Details
Storage Architecture
Ferrislog uses a log-structured storage model:
-
All operations (set, remove) are appended to a log file
-
An in-memory hash map tracks positions of the latest value for each key
-
On startup, the store rebuilds its state by replaying the log
-
Periodic compaction removes redundant entries to keep the log size manageable
Performance Considerations
-
Log Compaction: Automatically triggers when log exceeds 1024 bytes
-
Memory Usage: Keeps only key pointers in memory, not values
-
Recovery: Rebuilds state on startup by replaying the log
Future Enhancements
-
Multi-threaded operations for better performance
-
Time-to-live (TTL) for keys
-
Set the compaction value in kvs-address
-
Encryption when sending data