This project implements a simple Redis-like server in Rust, supporting basic commands such as PING
, ECHO
, SET
, and GET
. It also uses RwLock
for concurrency control to ensure thread-safe access to shared data.
-
Clone the repository:
git clone https://github.com/itmaybehimm/redis-clone-rust.git cd redis-clone-rust
-
Run the server using Cargo:
cargo run
To interact with the server, you can use redis-cli
. Open another terminal and use the following commands:
-
PING: Test the connection to the server.
redis-cli -p 6379 ping
-
ECHO: Echo back the message you send.
redis-cli -p 6379 echo "hello world"
-
SET: Set a key-value pair in the server.
redis-cli -p 6379 set mykey "myvalue"
-
GET: Get the value associated with a key.
redis-cli -p 6379 get mykey
This project uses RwLock
for concurrency control. RwLock
allows multiple readers or a single writer at any point in time, ensuring thread-safe access to the shared HashMap
that stores the key-value pairs.
Here is an example session using redis-cli
:
$ redis-cli -p 6379 ping
PONG
$ redis-cli -p 6379 echo "hello world"
"hello world"
$ redis-cli -p 6379 set mykey "myvalue"
"OK"
$ redis-cli -p 6379 get mykey
"myvalue"
This project is licensed under the MIT License. See the LICENSE file for details.