redis-async
An asynchronous Redis client library and a Redis CLI built in Rust and Tokio. Inspired by mini-redis.
Usage
Using the lib
First import dependencies:
# in Cargo.toml
[]
= "https://github.com/aden-q/redis-async.git"
Then use the lib in your Rust code:
use ;
async
More examples can be found in the examples directory.
Using the CLI
You can install the CLI as a binary or run it with Cargo.
To install as a binary into ~/.cargo/bin
:
~ cargo install --git https://github.com/aden-q/redis-async.git --bin redis-async-cli
Then you can run it:
~ redis-async-cli
To build and run without installation:
~ cargo build --release --bin redis-async-cli
Then you can run it:
~ ./target/release/redis-async-cli
To use the CLI, you first need to run a Redis server. Then you can run this CLI in either interactive mode or command line mode:
- Interactive mode:
In interactive mode, commands are case insensitive, but arguments are not, which means, Ping
, ping
, PING
they refer to the same Redis command.
> redis-async-cli
Interactive mode. Type 'exit' to quit.
127.0.0.1:6379> ping
PONG
127.0.0.1:6379> set key value
OK
127.0.0.1:6379> get key
"value"
- Command line mode:
~ redis-async-cli ping
PONG
~ redis-async-cli set key value
OK
~ redis-async-cli get key
"value"
For all available commands and options:
~ redis-async-cli -h
TLS/SSL
TBD. Not available yet.
Connection pooling
TBD. Not available yet.
RESP2/RESP3
Both RESP2 and RESP3 are supported. A protocol is set per connection.
By default, the connection runs in RESP2 mode. There is a HELLO
command you can
use to switch between different protocols.
Examples:
- CLI
Switch to RESP3:
~ redis-async-cli hello 3
Switc back to RESP2:
~ redis-async-cli hello 2
- Lib
use ;
async
Supported commands
This library is more on prototype. More commands will be added later on.
Development
Local build
To build the lib:
~ cargo build --lib
To build the CLI:
~ cargo build --bin redis-async-cli
For just users, refer to the local justfile for a list of targets:
~ just -l
Docs
~ cargo doc --no-deps --open
License
The project is licensed under the MIT license.