Skip to content

cs168898/redis-clone

Repository files navigation

redis-clone (WORK IN PROGRESS)

Building the Redis in-memory database with distributed caching to gain a deeper understanding of Redis technology and distributed systems.

Features

  • RESP (Redis Serialization Protocol) parsing and serialization for client-server communication.
  • In-memory key-value store supporting:
    • Simple string keys (SET, GET)
    • Hash maps (HSET, HGET, HGETALL)
  • Concurrency-safe database access using mutexes.
  • Append-Only File (AOF) persistence for durability and recovery.
  • Snapshotting to JSON files for fast backup and restoration.
  • Automatic periodic backups (auto-backup) in the background.
  • Command handlers for core Redis-like commands.
  • Compatible with redis-cli for testing.
  • Modular code structure for extensibility.
  • Graceful handling of malformed or invalid commands.

How to start

  1. In an terminal, type go run ., this will start the net/http server to listen to requests and accept commands.
  2. Go to a separate terminal and type 'redis-cli' to enter the command line interface for redis. You should see an ip address as the prompt.

Commands

  1. PING -> Returns PONG, typically used to test connections.
  2. SET [key] [value] -> Returns OK, used to set key value pairs. Data type: map[string]string{}.
  3. GET [key] -> Returns Value, used to find the value for specific keys.
  4. HSET [hash] [key] [value] -> Returns OK, typically used to set nested hashmap values. Data type: map[string]map[string]string.
  5. HGET [hash] [key] -> Returns Value, typically used to obtain values inside nested hashmaps.
  6. HGETALL [hash] -> Returns Value, typically used to list ALL key and values inside a specific hash.
  7. SNAPSHOT [fileName] -> Saves the current data into a data persistent storage in a file named [filename], this is used as a backup of current data or quick restoration(not implemented yet) after database restart.

Currently Developing

  1. Distributed Caching 2. Quick restoration

About

Building the Redis in-memory database to gain a deeper understanding of Redis technology

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages