A simple key-value store written in rust using the tokio runtime.
- redis-cli installed on your machine
- rust installed on your machine
- Clone this repo to your local machine using
git clone
cdinto the repo
- Install dependencies using
cargo install
- Run the app using
cargo run
- Build the app using
cargo build
This app uses the tokio runtime to handle asynchronous tasks. The tokio runtime is a low-level, zero-cost abstraction over futures. It provides several tools to help you write asynchronous code, including:
- The
tokio::spawnfunction for executing a future on a thread pool - Asynchronous versions of common std types, including TCP streams (
tokio::net::TcpStream), UDP sockets (tokio::net::UdpSocket), and channels (tokio::sync::mpscandtokio::sync::oneshot) - The
tokio::sync::Mutextype, an asynchronous version ofstd::sync::Mutex - Timer types, including
tokio::time::Instantandtokio::time::Duration - The
tokio::mainmacro, which makes it easy to run a tokio application
This app is a simple key-value store that allows you to set, get, and delete keys. It uses the redis protocol to communicate with the redis-cli. The redis-cli is a command line interface for redis that allows you to interact with the redis server. The redis-cli is a simple program that allows you to send commands to the server and read the replies sent back.
The redis protocol is a text-based protocol that uses the client-server model. The client sends a command to the server and the server responds with a reply. The client and server communicate using a TCP connection. The client sends a command to the server and the server responds with a reply. T
| Command | Description |
|---|---|
redis-cli set key value |
Set a key |
redis-cli get key |
Get a key |
redis-cli set key value ex time |
Set an expiration time for a key |
redis-cli ttl key |
Get the remaining time for a key |
redis-cli del key |
Delete a key |
redis-cli flush |
Delete all keys |
| Command | Description |
|---|---|
redis-cli set name john |
Set the key name to the value john |
redis-cli get name |
Get the value of the key name |
redis-cli set name john ex 10 |
Set the key name to the value john and set an expiration time of 10 seconds |
redis-cli ttl name |
Get the remaining time for the key name |
redis-cli del name |
Delete the key name |
redis-cli flush |
Delete all keys |
This project is licensed under the MIT License - see the LICENSE file for details