Redis client for the ntex framework.
- API Documentation
- ntex Documentation
- Minimum supported Rust version: 1.97 or later
Add ntex-redis and ntex with a runtime feature (tokio, compio,
neon-polling or neon-uring) to your Cargo.toml:
[dependencies]
ntex = { version = "4", features = ["tokio"] }
ntex-redis = "3"use ntex_redis::{RedisConnector, cmd};
#[ntex::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let redis = RedisConnector::new("127.0.0.1:6379").connect().await?;
// create list with one value
redis.exec(cmd::LPush("test", "value")).await?;
// get value by index
let value = redis.exec(cmd::LIndex("test", 0)).await?;
assert_eq!(value.unwrap(), "value");
// remove key
redis.exec(cmd::Del("test")).await?;
Ok(())
}RedisConnector also supports authentication (.password(..)), custom
I/O configuration (.config(..)) and custom connectors, e.g. for TLS
(.connector(..)). Use connect_simple() for a non-pipelined client
with pub/sub support, see examples/pubsub.rs.
This project is licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.