Skip to content

AryanParashar24/Redis-inspired-InMemoryDatabase-in-Golang

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Redis-Inspired In-Memory Database in Golang

Redis Go

A lightweight, Redis-inspired in-memory key-value database implemented in Golang, featuring:

  • Ultra-fast in-memory storage
    RESP (Redis Serialization Protocol) support
    AOF (Append-Only File) persistence
    Custom command handling
    Educational insight into Redis internals

This project highlights how modern in-memory databases work at their core and serves as a practical deep dive into networking, protocols, persistence, and storage engines.


Features

In-Memory Storage Engine

All data is stored inside memory for extremely fast reads/writes.
Inspired by Redis’ architecture: minimal latency and straightforward data access.

RESP Protocol Implementation

The server implements RESP, the same protocol used by Redis.

This means:

  • Structured command parsing
  • Consistent response format
  • Compatible with many Redis client behaviors
  • Easy debugging & learning experience

RESP supports arrays, bulk strings, integers, errors, and simple strings — all handled in your server’s parser.

AOF Persistence (Append-Only File)

Instead of snapshotting (like Redis RDB), this project uses AOF persistence:

  • Every write command (SET, DEL, etc.) is appended to a log file
  • On restart, the database replays the file to rebuild the dataset
  • Ensures durability while keeping the architecture simple and transparent

AOF makes it easy to understand how Redis ensures crash recovery.

Supported Commands

Command Description
PING Check server liveness
SET key value Store a key-value pair
GET key Retrieve the value of a key
HSET key Sets a key-value pair but in a HashMap inside a HashMap
HGET key Retrives the value of the key stored by HSET key.
HGETALL key To Retreive all the values stored by a key by HSET.

Architecture Overview

            ┌─────────────────────────┐
            │       Redis Client      │
            │  (RESP-Compatible Tool) │
            └───────────────▲─────────┘
                            │ RESP
                            │
                 ┌─────────┴──────────┐
                 │   Go Server Core   │
                 │ (Listener + Parser)|
                 └─────────▲──────────┘
                           │
                ┌──────────┴───────────┐
                │  In-Memory Data Store│
                └──────────▲───────────┘
                           │
                 ┌─────────┴──────────┐
                 │    AOF Persistence │
                 │ (Append & Replay)  │
                 └────────────────────┘

Getting Started

Clone the Repository

git clone https://github.com/AryanParashar24/Redis-inspired-InMemoryDatabase-in-Golang.git
cd Redis-inspired-InMemoryDatabase-in-Golang

Run the Server

go run main.go

Connect using redis-cli (optional)

redis-cli -p <PORT>

Try:

PING
SET hello world
GET hello
DEL hello

About

Built Redis inspired InMemoryDatabse using Golang

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages