High-performance Toy multi-protocol database engine built in Rust
WorkingDB is a blazing-fast, memory-optimized database that supports multiple protocols (Redis, Memcached), allowing you to integrate it into your existing stack without changing client code. Built on a zero-copy architecture with lock-free concurrency primitives, WorkingDB delivers microsecond-level latency while maintaining durability through append-only file (AOF) persistence.
- Multi-protocol support (Redis + Memcached compatibility)
- Lock-free memory architecture for concurrent operations
- Automatic persistence with AOF journaling
- Tokio-powered async I/O
- Auto protocol detection
- Built-in TTL support for expiring keys
- Background garbage collection
# Clone the repo
git clone <your-repo>
cd workingdb
# Build with optimizations
cargo build --release# Run with default settings (127.0.0.1:7777)
./target/release/workingdb
# Customize with environment variables
WORKINGDB_HOST=0.0.0.0 WORKINGDB_PORT=6380 WORKINGDB_DATA=/path/to/data ./target/release/workingdbConnect to WorkingDB using existing Redis or Memcached clients. The server automatically detects the protocol.
# Using redis-cli
redis-cli -h 127.0.0.1 -p 7777 SET mykey "Hello WorkingDB"
redis-cli -h 127.0.0.1 -p 7777 GET mykey
# From Python
import redis
r = redis.Redis(host='localhost', port=7777)
r.set('mykey', 'Hello WorkingDB')
value = r.get('mykey')
print(value) # b'Hello WorkingDB'# Using memcached CLI
echo -e "set mykey 0 0 11\r\nHello World\r\n" | nc localhost 7777
echo -e "get mykey\r\n" | nc localhost 7777
# From Python
import pymemcache
client = pymemcache.Client(('localhost', 7777))
client.set('mykey', 'Hello WorkingDB')
value = client.get('mykey')
print(value) # b'Hello WorkingDB'WorkingDB uses environment variables for configuration:
| Variable | Description | Default |
|---|---|---|
WORKINGDB_HOST |
Host to bind to | 127.0.0.1 |
WORKINGDB_PORT |
Port to listen on | 7777 |
WORKINGDB_DATA |
Data directory for persistence | ./data |
GET key- Get the value of a keySET key value [EX seconds]- Set key to value with optional expirationDEL key- Delete a keyPING- Test connectionINFO- Server information
get <key>- Get the value of a keyset <key> <flags> <exptime> <bytes> [noreply]- Set key with optional expirationdelete <key> [noreply]- Delete a keystats- Server statisticsversion- Server version
WorkingDB is built with a modular Rust architecture:
src/
├── core/ - Core database state management
├── storage/ - Memory and disk storage engines
├── network/ - Network protocol implementations
├── persistence/ - Durability and recovery
├── query/ - SQL query parsing and execution
└── util/ - Utility functions and helpers
WorkingDB uses an append-only file (AOF) for durability. All write operations are logged to the AOF and replayed on startup to recover the in-memory state. No data loss occurs, even in the event of a crash.
# Run tests
cargo test
# Run with development features
cargo run --features devWorkingDB is designed for high throughput and low latency:
- Memory-optimized storage with sharded hash tables
- Lock-free read paths for concurrent access
- Tokio async runtime for non-blocking I/O
- Zero-copy deserialization for network protocols
- SQL query engine
- Distributed clustering with Raft consensus
- Advanced compression for values
- RESP3 protocol support
- io_uring-based disk I/O
- Extended command set compatibility
Contributions are welcome. Please submit a Pull Request.
WorkingDB is licensed under the MIT License.