Skip to content

About

Redis client

Resources

Stars

47 stars

Watchers

3 watching

Forks

Repository files navigation

ntex redis build status codecov crates.io

Redis client for the ntex framework.

Documentation & community resources

Usage

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"

Example

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.

License

This project is licensed under either of

at your option.

About

Redis client

Resources

Stars

47 stars

Watchers

3 watching

Forks

Releases

Packages

Used by

Contributors

Languages