Video series · 21 parts
A from-scratch Redis server in Go: a TCP server and the RESP protocol, AOF and RDB persistence, transactions, key expiry, memory eviction (LRU, LFU, random), AUTH, MONITOR and INFO.

I build a Redis clone in Go from scratch, starting with a TCP server on port 6379 and a parser for RESP, the Redis Serialization Protocol. I install Redis to get the official redis-cli, stop the bundled Redis server…

I recap RESP and then build the GET and SET command handlers plus the client reply writer for my Go Redis clone, turning the server into a working in-memory key-value store. I go through RESP's core types: + for simple…

I add concurrency support to my Go Redis clone with a read-write mutex and build a minimal redis.conf parser that will drive data persistence. I replace the bare map with a Database struct that holds the store and a…

I implement append-only file (AOF) persistence for my Go Redis clone in Part 4, comparing Redis's AOF and RDB approaches and building the AOF side. I record every SET command as a RESP array in backup.aof using the…

I build RDB data persistence into my Go Redis clone by snapshotting the whole in-memory store to disk and loading it back on server start. I set up snapshot trackers backed by time.Ticker so each configured save rule…

I fix my Go Redis clone’s concurrency model and implement the DEL, EXISTS, and KEYS commands. I move connection acceptance into an infinite loop, handle each client in its own goroutine with a WaitGroup, and close…

I implement the SAVE and BGSAVE commands in my Go Redis clone, after tightening up the RDB snapshot code and fixing concurrency and file-handling bugs. I add a read lock around RDB encoding, switch the save file to…

I implement the DBSIZE and FLUSHDB commands in my Go Redis clone, showing how to return the number of keys and wipe the entire database safely. For DBSIZE, I take a read lock and return the length of the in-memory map…

I add SHA-256 checksum protection to my Go Redis clone's RDB save path so every snapshot is verified against what actually lands on disk. I encode the database into an in-memory buffer, hash it, write the bytes, flush…

I implement AUTH and password protection in my Go Redis clone by adding requirepass, tracking per-client authentication, and blocking unauthenticated commands. I add requirepass dolphins to the config, parse it into a…

I build the EXPIRE and TTL commands into my Go Redis clone by refactoring the database store from map[string]string to map[string]*Key, where each key holds its value and an expiry time.Time. I add database-level Set…

I build the BGREWRITEAOF command for my Go Redis clone, which compacts an append-only file by replacing old, outdated SET commands with only the latest key values. I demonstrate the problem by setting the same key to…

I implement Redis-style database transactions in my Go Redis clone by adding MULTI, EXEC, and DISCARD command handlers. I add a transaction struct to the app state, queue commands inside the handle function after…

I add approximate memory tracking and a maxmemory limit to my Go Redis clone, then enforce a no-eviction policy that rejects writes when the server runs out of memory. I calculate each key's approximate usage by adding…

I implement the allkeys-random eviction policy for my Go Redis clone: when the database is out of memory, I sample a configurable number of keys and delete them until enough memory is freed for the new write. I add…

I fix the AOF restore bug in my Go Redis clone where the server only loaded the first key from the append-only file and ignored every command after it. The root cause was that readArray created a fresh bufio.Reader for…

I implement the allkeys-lru and allkeys-lfu eviction policies in my Go Redis clone by sorting the sampled keys by last access time for LRU or access count for LFU, then calling evictUntilMemoryFree until enough memory…

I fix a missing mutex unlock in the GET path of my Go Redis clone, refactor the growing codebase into focused files, and implement the MONITOR command so one client can observe every command other clients run. Along…

I build out the INFO command for my Go Redis clone, adding the server, clients, and memory sections while leaving persistence and general stats for the final part. I create an Info struct and a build method that pulls…

I finish the INFO command and fix AOF memory handling in my Go Redis clone, wrapping up the 20-part series. I add the persistence and general INFO categories, which means tracking RDB last-save time and save count, AOF…

I fix an AOF rewrite bug in my Go Redis clone where commands buffered during BGREWRITEAOF were never flushed to the rewritten file. A viewer caught that after the rewrite clears and rebuilds the AOF, any new commands…


Dude, you’re at the bottom of my landing page.
Just book a call already if you’re that interested.
You scrolled all the way here.