Skip to content

zulerne/redis-go

Repository files navigation

redis-go

CI codecov Go Version License: MIT

A Redis server implementation in Go, featuring RESP protocol support, in-memory data structures, and concurrent client handling.

Features

  • RESP (Redis Serialization Protocol) for client-server communication
  • String, List, and Stream data types
  • Thread-safe operations with goroutine-based connection handling
  • Blocking list operations (BLPOP)
  • TTL support with lazy deletion
  • Graceful shutdown with structured logging (slog)

Getting Started

Prerequisites

  • Go 1.26+
  • Task (optional, for task automation)

Run

task run
# or
go run ./cmd/server

The server starts on 0.0.0.0:6379 by default.

Build

task build
# or
go build -o redis-server ./cmd/server

Connect

redis-cli -h localhost -p 6379

Supported Commands

Connection

  • PING — test connectivity
  • ECHO <message> — echo the given string

String

  • SET <key> <value> [EX seconds] [PX milliseconds] — set key with optional TTL
  • GET <key> — get value by key

List

  • RPUSH <key> <value> [value ...] — append to the end
  • LPUSH <key> <value> [value ...] — prepend to the start
  • LRANGE <key> <start> <stop> — get range (supports negative indices)
  • LLEN <key> — get length
  • RPOP <key> [count] — remove and return from the end
  • LPOP <key> [count] — remove and return from the start
  • BLPOP <key> <timeout> — blocking pop from head

Stream

  • XADD <key> <ID> <field> <value> [field value ...] — add entry

Generic

  • TYPE <key> — get key type (string, list, stream, none)

Architecture

cmd/server/          Entry point
internal/
  commands/          Command handlers
  config/            Server configuration
  server/            TCP server and connection handling
  store/             In-memory data store
pkg/
  resp/              RESP protocol parser and encoder

Development

task test       # run tests with -race
task lint       # run golangci-lint
task check      # lint + test
task coverage   # test with coverage report
task fmt        # format code

License

This project is open source and available for educational purposes.

Note: This is an educational Redis implementation. For production use, see Redis.

About

No description, website, or topics provided.

Resources

License

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors