A Redis-compatible storage engine in Go, backed by Pebble (pure-Go LSM-tree).
- Redis compatible — RESP2/RESP3, drop-in replacement (
redis-cliworks directly) - Pebble storage — pure Go, no CGo, WAL + tunable fsync
- Data structures — String, Hash, List, Set, Sorted Set, Geo, Bitmap, HyperLogLog, Stream, Vector Set (with adaptive encodings; Geo reuses ZSet, Bitmap reuses String; Vector Set P0: VADD subset, VCARD/VDIM/VEMB/VREM/VRANDMEMBER, brute-force VSIM)
- Expiration — key-level TTL + Hash field expiration (HEXPIRE family), lazy + background active deletion
- Replication — PSYNC (full RDB + backlog partial sync), read-only replicas
- Memory management — maxmemory + 8 eviction policies (allkeys/volatile × lru/lfu/random/ttl), runtime CONFIG
- Keyspace notifications —
CONFIG SET notify-keyspace-events KEAfull-class events (g/s/h/l/z/x/e/m), keyspace + keyevent channels - New commands — GETSET/SETEX/PSETEX/SETNX/TOUCH, LMOVE/BLMOVE/RPOPLPUSH/BRPOPLPUSH, READONLY/READWRITE, OBJECT IDLETIME/FREQ, HEXPIRETIME/HPEXPIRETIME, SUBSTR, SWAPDB, COMMAND LIST
- Live command stream — MONITOR / CLIENT MONITOR with per-conn serialized outbound pipe + per-conn write lock
- Client-side caching — CLIENT TRACKING (on/off, BCAST/PREFIX, OPTIN/CACHING, OPTOUT, NOLOOP); invalidation via RESP3 push / RESP2
__redis__:invalidate, independent of notify-keyspace-events - Monitoring — six-section INFO + SLOWLOG + Prometheus
/metrics - Server-side TLS — listener-side
[server] tls_cert/tls_key(outbound dial-side TLS follows[tls]config viatlsdial)
# Build (static binary, no CGo)
make build
# Start (default gedis.toml, port 6380)
./bin/gedis
# Connect with redis-cli
redis-cli -p 6380# Build image (multi-stage, scratch runtime ~25MB)
make docker
# Single node
docker run -d -p 6380:6380 -v gedis-data:/data gedis:latest
# Local master-replica test
make compose-up
redis-cli -p 6381 REPLICAOF 127.0.0.1 6380
make compose-downTOML format (see gedis.toml; inside containers use gedis.docker.toml):
[server]
host = "127.0.0.1"
port = 6380
[storage]
datadir = "./data"
[memory]
maxmemory = 1073741824
policy = "allkeys-lru" # or volatile-lru
[persistence]
appendonly = true
fsync = "everysec" # always | everysec | no
[metrics]
enabled = false
port = 9121Runtime tuning: CONFIG SET maxmemory <bytes>, CONFIG SET maxmemory-policy <allkeys-lru|allkeys-lfu|allkeys-random|volatile-lru|volatile-lfu|volatile-random|volatile-ttl|noeviction>, CONFIG GET maxmemory, CONFIG SET notify-keyspace-events <KgEgse...>.
# On the replica (read-only mode turns on automatically)
REPLICAOF <master-host> <master-port>
# Promote to master
REPLICAOF NO ONEINFO [server|clients|memory|stats|replication|keyspace]
SLOWLOG GET [n] | LEN | RESET
curl localhost:9121/metrics # requires [metrics] enabledgedis/
├── cmd/gedis/ # Main entrypoint
├── internal/
│ ├── network/ # TCP server + Router + stats/slowlog
│ ├── protocol/ # RESP2/RESP3 codec
│ ├── storage/ # Pebble storage + WAL/fsync/batch/memory accounting
│ ├── datastruct/ # Encodings (string/hash/list/set/zset/stream/hll + adaptive; geo→zset, bitmap→string)
│ ├── commands/ # All command implementations
│ ├── replication/ # Backlog/RDB/Hub/replica client
│ ├── metrics/ # Prometheus exposition
│ └── config/ # TOML configuration
├── docs/
│ └── adr/ # Architecture decision records
├── Dockerfile # Multi-stage build
├── docker-compose.yml # Local master-replica test
├── gedis.toml # Local config example
└── gedis.docker.toml # In-container config
make test # Full suite (-race)
make vet # Static checks
make bench # BenchmarksRDB works both ways: --load-rdb imports a real Redis RDB file into an empty database at startup, and SAVE/BGSAVE export a real RDB dump (BGSAVE in background, snapshot-consistent); BGREWRITEAOF returns an honest error (no AOF engine); CONFIG REWRITE persists the live allowlist (maxmemory/policy, dbfilename, notify-keyspace-events) back to the config file.
MIT License