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?;
let _ = client.flushall(false).await?;
// convert responses to many common Rust types
let foo: Option<String> = client.get("foo").await?;
assert_eq!(foo, None);
let _: () = client.set("foo", "bar", None, None, false).await?;
// or use turbofish to declare types. the first type is always the response.
println!("Foo: {:?}", client.get::<String, _>("foo".to_owned()).await?);
// or use a lower level interface for responses to defer parsing, etc
let foo: RedisValue = client.get("foo").await?;
assert!(foo.is_string());
let _ = client.quit().await?;
// and/or wait for the task driving the connection to finish
let _ = jh.await;
Ok(())
}
See the github repository for more examples.
Re-exports
Modules
Redis client implementations.
Error structs returned by Redis commands.
Utility functions for manipulating global values that can affect performance.
Traits that implement portions of the Redis interface.
monitor
monitor
An interface to run the MONITOR
command.
Client pooling structs.
Convenience module to import a RedisClient
, all possible interfaces, error types, and common argument types or return value types.
The structs and enums used by the Redis client.
An interface for interacting directly with sentinel nodes. Utility functions used by the client that may also be useful to callers.