Gedis KV is a small Redis-like key-value database written in Go.
It exposes a Redis-compatible TCP protocol using redcon, stores data in memory, and persists write operations through an append-only binary log so the database can replay state on restart.
- Redis-style TCP server
- In-memory key-value storage
- Append-only binary log for SET and DEL recovery
- Thread-safe reads and writes with
sync.RWMutex - Basic TTL support for keys
- SET options:
NX,XX,EX,PX,EXAT,PXAT - Structured logging with Zap
PINGQUITSET key valueGET keyDEL key [key ...]
- Go 1.18+
- Make
git clone https://github.com/Subhasish-Behera/Gedis_KV.git
cd Gedis_KV
go mod downloadmake buildThis creates the server binary at:
./bin/server
make runBy default, the server listens on:
localhost:3000
and stores its append-only log at:
default.db
You can also pass custom flags directly:
./bin/server -addr localhost:3000 -db-path ./gedis.dbUsing redis-cli:
redis-cli -p 3000PING
SET name gedis
GET name
DEL name
QUIT
Example with TTL:
SET session abc123 EX 60
GET session
Example with conditional writes:
SET user alice NX
SET user bob XX
Gedis KV keeps the active dataset in memory. Mutating commands are written to an append-only binary log:
SETappends a set eventDELappends a delete event- On startup, the database replays the log to rebuild state
The binlog is flushed on close and periodically synced in the background.
cmd/
main.go # server entrypoint
pkg/
server.go # Redis protocol command handling
db.go # in-memory database and persistence replay
binlog.go # append-only log lifecycle
binlog_reader.go # binary log reader
binlog_writer.go # binary log writer
db_test.go # database tests
make testor:
go test ./...