[−][src]Crate fred
Fred
A client library for Redis based on Futures and Tokio.
extern crate fred; extern crate tokio_core; extern crate futures; use fred::RedisClient; use fred::types::*; use tokio_core::reactor::Core; use futures::{ Future, Stream }; fn main() { let config = RedisConfig::default(); let mut core = Core::new().unwrap(); let handle = core.handle(); println!("Connecting to {:?}...", config); let client = RedisClient::new(config); let connection = client.connect(&handle); let commands = client.on_connect().and_then(|client| { println!("Client connected."); client.select(0) }) .and_then(|client| { println!("Selected database."); client.info(None) }) .and_then(|(client, info)| { println!("Redis server info: {}", info); client.get("foo") }) .and_then(|(client, result)| { println!("Got foo: {:?}", result); client.set("foo", "bar", Some(Expiration::PX(1000)), Some(SetOptions::NX)) }) .and_then(|(client, result)| { println!("Set 'bar' at 'foo'? {}.", result); client.quit() }); let (reason, client) = match core.run(connection.join(commands)) { Ok((r, c)) => (r, c), Err(e) => panic!("Connection closed abruptly: {}", e) }; println!("Connection closed gracefully with error: {:?}", reason); }
Modules
error | Error handling. |
metrics | Structs for tracking latency and payload size metrics. |
sync |
|
types | Configuration options, return value types, etc. |
Structs
RedisClient | A Redis client. |