Skip to content
EcolashPublic

About

๐—ฅ๐—ฒ๐—ฑ๐—ถ๐˜€ ๐—ฆ๐—ฒ๐—ฟ๐˜ƒ๐—ฒ๐—ฟ + ๐—–๐—Ÿ๐—œ | ๐—ฃ๐—ฒ๐—ฟ๐˜€๐—ถ๐˜€๐˜๐—ฒ๐—ป๐—ฐ๐—ฒ, ๐—ฅ๐—ฒ๐—ฝ๐—น๐—ถ๐—ฐ๐—ฎ๐˜๐—ถ๐—ผ๐—ป, ๐—ฃ๐˜‚๐—ฏ/๐—ฆ๐˜‚๐—ฏ, ๐—ฆ๐˜๐—ฟ๐—ฒ๐—ฎ๐—บ๐˜€, ๐—ง๐—จ๐—œ

Topics

Resources

Stars

6 stars

Watchers

0 watching

Forks

Latest commit

ย 

History

147 Commits

Folders and files

NameName
Last commit message
Last commit date
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Redis โ€” Go Implementation

A from-scratch Redis server and interactive client CLI written in Go. Credits: Build Your Own Redis Challenge : CodeCrafters

Demo


What's in this repo

Binary Path Description
redis-server app/ Full Redis server : RESP protocol, persistence, replication, pub/sub
redis-cli cmd/redis-cli/ Rich interactive client : TUI REPL, autocomplete, live pub/sub feed

Server

Run

# Default (port 6379)
go run ./app/

# Custom port
go run ./app/ --port 6380

# With RDB persistence
go run ./app/ --port 6379 --dir /tmp --dbfilename dump.rdb

# With AOF persistence
go run ./app/ --port 6379 --appendonly yes --appendfilename appendonly.aof

# As a replica
go run ./app/ --port 6380 --replicaof "127.0.0.1 6379"

Supported commands

Category Commands
Basic PING ECHO TYPE INFO
String SET GET INCR DECR
List LPUSH RPUSH LPOP RPOP LLEN LRANGE BLPOP
Stream XADD XRANGE XREAD
Sorted set ZADD ZRANGE ZRANK ZSCORE ZCARD ZREM
Geo GEOADD GEOPOS GEODIST GEOSEARCH
Pub/Sub SUBSCRIBE PSUBSCRIBE UNSUBSCRIBE PUNSUBSCRIBE PUBLISH
Transaction MULTI EXEC DISCARD WATCH UNWATCH
Replication REPLCONF PSYNC WAIT
ACL / Auth AUTH ACL
Config / Keys CONFIG KEYS

Concurrency model: each client connection runs in its own goroutine; the store is protected by sync.RWMutex so reads run concurrently and writes are serialised โ€” similar to Redis but via OS threads instead of an event loop.


CLI

Run

# Connect to local server
go run ./cmd/redis-cli/

# Custom host / port / password
go run ./cmd/redis-cli/ --host 127.0.0.1 --port 6380 --password secret

# Scripted demo (good for recording)
go run ./cmd/redis-cli/ --demo

Features

  • Startup banner โ€” ASCII logo, connection status, ping latency, server version
  • Autocomplete โ€” fuzzy command suggestions with synopsis, context-aware (suppressed during pub/sub)
  • Typo correction โ€” Levenshtein distance hint when a command isn't recognised
  • Color-coded output โ€” โœ“ green for OK, โœ— red for errors, cyan integers, dim nil
  • Sorted set tables โ€” ZRANGE ... WITHSCORES renders as an aligned member/score table
  • Stream cards โ€” XRANGE/XREAD renders each entry with ID and field/value rows
  • GEO tables โ€” GEOPOS/GEODIST rendered as labelled coordinate tables
  • Transaction mode โ€” prompt changes to TXโ€บ (yellow), queued commands show โฌก QUEUED
  • Pub/Sub live feed โ€” Bubble Tea view with timestamped ๐Ÿ”” messages, Ctrl+C to exit and unsubscribe
  • Built-in help โ€” HELP lists all commands by category; HELP <cmd> shows synopsis and example

Build

# Build both binaries
go build -o redis-server ./app/
go build -o redis-cli    ./cmd/redis-cli/

# Run all tests
go test ./...

progress-banner

About

๐—ฅ๐—ฒ๐—ฑ๐—ถ๐˜€ ๐—ฆ๐—ฒ๐—ฟ๐˜ƒ๐—ฒ๐—ฟ + ๐—–๐—Ÿ๐—œ | ๐—ฃ๐—ฒ๐—ฟ๐˜€๐—ถ๐˜€๐˜๐—ฒ๐—ป๐—ฐ๐—ฒ, ๐—ฅ๐—ฒ๐—ฝ๐—น๐—ถ๐—ฐ๐—ฎ๐˜๐—ถ๐—ผ๐—ป, ๐—ฃ๐˜‚๐—ฏ/๐—ฆ๐˜‚๐—ฏ, ๐—ฆ๐˜๐—ฟ๐—ฒ๐—ฎ๐—บ๐˜€, ๐—ง๐—จ๐—œ

Topics

Resources

Stars

6 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages