Skip to content

nassdaq/workingdb

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

6 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

WorkingDB

High-performance Toy multi-protocol database engine built in Rust

๐Ÿš€ What is WorkingDB?

WorkingDB is a blazing-fast, memory-optimized database that speaks multiple protocols (Redis, Memcached) so you can plug 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 its append-only file (AOF) persistence.

Key Features:

  • ๐Ÿ”ฎ 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

๐Ÿ› ๏ธ Getting Started

Installation

# Clone the repo
git clone https://github.com/yourusername/workingdb.git
cd workingdb

# Build with optimizations
cargo build --release

Running WorkingDB

# 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/workingdb

๐Ÿ’ป Client Connections

Connect to WorkingDB using existing Redis or Memcached clients - the server auto-detects the protocol.

Redis Example

# 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'

Memcached Example

# 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'

๐Ÿ”ง Configuration

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

๐Ÿ“‹ Supported Commands

Redis Commands

  • GET key - Get the value of a key
  • SET key value [EX seconds] - Set key to value with optional expiration
  • DEL key - Delete a key
  • PING - Test connection
  • INFO - Server information

Memcached Commands

  • get <key> - Get the value of a key
  • set <key> <flags> <exptime> <bytes> [noreply] - Set key with optional expiration
  • delete <key> [noreply] - Delete a key
  • stats - Server statistics
  • version - Server version

๐Ÿ—๏ธ Architecture

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

๐Ÿ” Data Persistence

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, even in the event of a crash.

๐Ÿงช Development

# Run tests
cargo test

# Run with development features
cargo run --features dev

๐Ÿ“ˆ Performance

WorkingDB 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

๐Ÿ”ฎ Roadmap

  • 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

๐Ÿค Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

๐Ÿ“„ License

WorkingDB is licensed under the MIT License - see the LICENSE file for details.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages