TinyDB is a lightweight, Redis-like in-memory database built in Go (Golang).
It provides a simple TCP server that understands a subset of Redis-style commands (SET, GET, HSET, HGET, etc.) with Append-Only File (AOF) persistence and peer-to-peer extensibility for future distributed setups.
- ⚡ In-Memory Database with Redis-like command syntax.
- 💾 AOF Persistence — data is logged to disk to survive restarts.
- 🧠 Command Handlers for basic key/value and hash operations.
- 🧩 Pluggable Architecture — modular packages for server, memory, AOF, peers, and protocol.
- 🔌 TCP Protocol Server that can be interacted with via
redis-cliornetcat. - 📡 Peer System (WIP) — planned cluster support for multiple nodes.
Clone the repository and install dependencies:
git clone https://github.com/muhammadolammi/tinydb.git
cd tinydb/tinydb
go mod tidy Build the binary:
make buildOr run directly:
go run main.goBy default, TinyDB listens on port 6379 (configurable via .env).
Start the Server
go run main.goYou should see:
2025/10/07 22:00:00 starting server
INFO server running listenAddr=:6379
Connect via redis-cli or netcat
TinyDB uses a Redis-like RESP protocol, so you can use redis-cli:
redis-cli -p 6379Or netcat:
nc localhost 6379Supported Commands
| Command | Description | Example |
|---|---|---|
SET key value |
Store a string value | SET name "TinyDB" |
GET key |
Retrieve a string value | GET name |
HSET key field value |
Set a field in a hash | HSET user name Olamide |
HGET key field |
Get a field from a hash | HGET user name |
DEL key |
Delete a key | DEL name |
EXISTS key |
Check if key exists | EXISTS name |
All commands are case-insensitive.
TinyDB logs all mutating commands (SET, HSET, etc.) to an Append-Only File stored locally. When the server restarts, it automatically replays the AOF log to rebuild the in-memory state.
TinyDB consists of several decoupled components:
| Package | Responsibility |
|---|---|
server |
TCP listener, event loop, connection management |
protocol |
RESP parser/writer for client communication |
memory |
Command handlers and data store |
aof |
Append-only file writer/reader for persistence |
peer |
Peer connection management (for clustering, WIP) |
$ redis-cli -p 6379
127.0.0.1:6379> SET name TinyDB
OK
127.0.0.1:6379> GET name
"TinyDB"
127.0.0.1:6379> HSET user name Olamide
OK
127.0.0.1:6379> HGET user name
"Olamide"
| Command | Description |
|---|---|
make build |
Build the TinyDB binary |
make run |
Run the server directly |
make clean |
Remove compiled files |
TinyDB reads from a .env file at the project root.
Example:
PORT=6379Clustered mode with replication
Pub/Sub messaging
Expiry and TTL support
Benchmark tooling
Web admin dashboard
Muhammad Olamide 📧 Email
This project is licensed under the MIT License.