Crate fred[][src]

Expand description

Fred

An async client library for Redis based on Tokio and Futures.

Examples

use fred::prelude::*;
use std::future::Future;

#[tokio::main]
async fn main() -> Result<(), RedisError> {
  let config = RedisConfig::default();
  let policy = ReconnectPolicy::default();
  let client = RedisClient::new(config);

  // connect to the server, returning a handle to a task that drives the connection
  let jh = client.connect(Some(policy));
  // wait for the client to connect
  let _ = client.wait_for_connect().await?;
   
  println!("Foo: {:?}", client.get("foo").await?);
  let _ = client.set("foo", "bar", None, None, false).await?;
  println!("Foo: {:?}", client.get("foo".to_owned()).await?);

  let _ = client.quit().await?;
  // wait for the task driving the connection to finish
  let _ = jh.await;
  Ok(())
}

See the github repository for more examples.

Modules

The primary interface for communicating with the Redis server.

Error structs returned by Redis commands.

Utility functions for manipulating global values that can affect performance.

Metrics describing the latency and size of commands sent to the Redis server.

Client pooling structs.

Convenience module to use a RedisClient, RedisError, and any argument types.

The structs and enums used by the Redis client.