Building the Redis in-memory database with distributed caching to gain a deeper understanding of Redis technology and distributed systems.
- 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
)
- Simple string keys (
- 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.
- In an terminal, type
go run .
, this will start the net/http server to listen to requests and accept commands. - 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.
PING
-> Returns PONG, typically used to test connections.SET [key] [value]
-> Returns OK, used to set key value pairs. Data type: map[string]string{}.GET [key]
-> Returns Value, used to find the value for specific keys.HSET [hash] [key] [value]
-> Returns OK, typically used to set nested hashmap values. Data type: map[string]map[string]string.HGET [hash] [key]
-> Returns Value, typically used to obtain values inside nested hashmaps.HGETALL [hash]
-> Returns Value, typically used to list ALL key and values inside a specific hash.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.
- Distributed Caching
2. Quick restoration