A lightweight Redis-compatible server written in Go. Rego speaks the RESP protocol so it can be driven by standard Redis clients while providing core Redis data structures, replication, and persistence features.
- RESP protocol compatibility for use with existing Redis tooling
- String storage with NX/XX and PX/EX options plus atomic
INCR
- Durable state via RDB parsing on startup with optional replica mode
- Transaction support (
MULTI
/EXEC
/DISCARD
) and synchronous replication viaWAIT
- Stream primitives (
XADD
,XRANGE
,XREAD
) for append-only data - List data type with blocking pops (
BLPOP
) for queue-style workloads - Pub/Sub channels with
SUBSCRIBE
,UNSUBSCRIBE
, andPUBLISH
- Sorted sets backing both ZSET commands and geospatial queries (
GEO*
)
- Go 1.21 or higher
# Run the server with default settings
./run.sh
# Run the server with custom settings
./run.sh --port 6380 --dir /path/to/data --dbfilename custom.rdb
To create a replica instance:
# Start the master on the default port (6379)
./run.sh
# Start a replica on port 6380
./run.sh --port 6380 --replicaof "localhost 6379"
app/
– Server source codemain.go
– Process entrypoint, connection handling, CLI flagshandler.go
– RESP command registry and command implementationsresp.go
– RESP encoder/decoderkey-value-store.go
– In-memory store with TTL managementconfig.go
– Runtime configuration and replication offsetsreplica.go
– Master/replica synchronization logicrdb_parser.go
– RDB file parser and loaderstream.go
,stream_manager.go
– Stream data structure and range/read helperslist.go
,list_manager.go
– List operations plus blocking pop coordinationpubsub_manager.go
– Channel subscription tracking and message fan-outsorted_set.go
– Sorted set storage used by ZSET and GEO commands
run.sh
– Convenience script to build and run the servercreate_rdb.sh
,dump.rdb
,empty.rdb
– Test fixtures for RDB parsing
- Basic:
PING
,ECHO
- Strings:
SET
,GET
,INCR
,TYPE
- Keys:
KEYS
- Configuration & replication:
CONFIG GET
,INFO REPLICATION
,REPLCONF
,PSYNC
,WAIT
- Transactions:
MULTI
,EXEC
,DISCARD
- Streams:
XADD
,XRANGE
,XREAD
- Lists:
LPUSH
,RPUSH
,LRANGE
,LLEN
,LPOP
,BLPOP
- Pub/Sub:
SUBSCRIBE
,UNSUBSCRIBE
,PUBLISH
- Sorted sets:
ZADD
,ZRANGE
,ZRANK
,ZCARD
,ZSCORE
,ZREM
- Geospatial:
GEOADD
,GEOPOS
,GEODIST
,GEOSEARCH
The server is intentionally focused on the subset of Redis features above, making it a practical playground for understanding how Redis works under the hood.