Skip to content

itmaybehimm/redis-clone-rust

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Redis Rust Server

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.

Getting Started

Prerequisites

  • Rust (Make sure you have Rust installed)
  • Redis CLI (for testing the server)

Running the Server

  1. Clone the repository:

    git clone https://github.com/itmaybehimm/redis-clone-rust.git
    cd redis-clone-rust
  2. Run the server using Cargo:

    cargo run

Using Redis CLI

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

Concurrency Control

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.

Example Session

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"

License

This project is licensed under the MIT License. See the LICENSE file for details.

Acknowledgements

  • Tokio for asynchronous runtime.
  • Redis for inspiration.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages