Crate darkredis[][src]

Asyncronous redis client built using futures and async await, with optional connection pooling.

use darkredis::*;

// Create a connection pool with 4 connections
let pool = ConnectionPool::create("127.0.0.1:6379".into(), None, 4).await.unwrap();
let mut connection = pool.get().await; // Grab a connection from the pool

connection.set("some-key", "Hello, world!").await.unwrap();
assert_eq!(connection.get("some-key").await.unwrap(), Some("Hello, world!".into()));

Structs

Command

Struct for defining commands manually. If you want to run multiple commands in a pipeline, use CommandList.

CommandList

Struct for defining commands manually, which allows for pipelining of several commands. If you need to only run one command, use Command, which has almost the same API.

Connection

A connection to Redis. Copying is cheap as the inner type is a simple, futures-aware, Arc<Mutex>, and will not create a new connection. Use a ConnectionPool if you want to use pooled connections. Alternatively, there's the deadpool-darkredis crate. Every convenience function can work with any kind of data as long as it can be converted into bytes. Check the Redis command reference for in-depth explanations of each command.

ConnectionPool

A connection pool. Clones are cheap and is the expected way to send the pool around your application.

HScanBuilder

Builder to build a HSCAN command. Borrows all its data.

HScanStream

A Stream of results from running HSCAN. The same key might appear multiple times, and polling until the stream is empty will return all matching fields and values in the hash set.

MSetBuilder

A builder struct for commands where you set multiple values at once. It utilizes references to ensure that it does not copy any of the data given to it. It supports the classic builder-pattern, as well as a mutable pattern.

Message

A message received from a channel.

MessageStream

A stream of Messages.

PMessage

A message received from a channel (Pattern version)

PMessageStream

A stream of PMessages. See MessageStream for more info.

ResponseStream

A stream of responses from a pipelined command.

ScanBuilder

Builder to build a SCAN or SSCAN command. Borrows all its data.

ScanStream

A Stream of results from running SCAN or SSCAN. The same value might appear multiple times. Polling until the stream is empty will return all matched elements.

Enums

DataType

An enum corresponding to every Redis type.

Error

The darkredis error type.

Value

Enum depicting the various possible responses one can get from Redis.

Traits

ToSocketAddrs

Converts or resolves without blocking to one or more SocketAddr values.

Type Definitions

Result

Result type used in the whole crate.