=================================
This project implements a basic Redis-like server in Go. It supports a few core commands including PING
, SET
, GET
, HSET
, and HGET
.
- PING: Returns "PONG" to confirm the server is running.
- SET: Stores a key-value pair in memory.
- GET: Retrieves the value associated with a given key.
- HSET: Stores a key-value pair in a hash map (nested map).
- HGET: Retrieves the value associated with a key in a hash map.
The Value
struct is used to represent various data types received from clients, supporting serialization and deserialization for the RESP (REdis Serialization Protocol).
Commands are handled by specific functions defined in the Handlers
map:
ping(args []Value)
: Responds with "PONG" or the passed argument.set(args []Value)
: Sets a key to a specified value.get(args []Value)
: Retrieves the value for a given key.hset(args []Value)
: Sets a key-value pair in a hash.hget(args []Value)
: Retrieves a value from a hash.
Read-write mutexes are used to manage concurrent read and write access to the in-memory data structures.
The server reads and writes data according to the RESP protocol, which allows clients to communicate with the server in a standardized format.
Make sure you have Go installed on your machine. You can download it from golang.org.
-
Clone the repository:
bash Copy code `git clone <repository-url>
cd `
-
Build and run the server:
bash
Copy code
go run main.go
We plan to extend the functionality of this Redis-like server by adding more commands, including:
LPUSH
: Inserts one or more values at the head of a list.
RPUSH
: Inserts one or more values at the tail of a list.
LPOP
: Removes and returns the first element of a list.
RPOP
: Removes and returns the last element of a list.
ZADD
: Adds one or more members to a sorted set, or updates the score of an existing member.
We welcome contributions to this project! Please see our CONTRIBUTING.md for guidelines on how to contribute.
By participating in this project, you agree to abide by our Code of Conduct.