Created
March 16, 2018 17:10
-
-
Save badboy/b64026f239df5279974da88a14d9fe41 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extern crate redis; | |
use std::error::Error; | |
use redis::{Commands}; | |
fn do_redis_code() -> redis::RedisResult<()> { | |
let client = try!(redis::Client::open("redis://127.0.0.1/")); | |
let con = try!(client.get_connection()); | |
let () = redis::cmd("HMSET").arg("a").arg(&["fa", "1", "fb", "2"]).query(&con).unwrap(); | |
let data : Vec<String> = con.hget("a", &["fa", "fb"]).unwrap(); | |
println!("Found: {:?}", data); | |
let data : Vec<String> = con.hget("a", &["fa", "fc"]).unwrap(); | |
println!("Found: {:?}", data); | |
let data : Vec<String> = con.hget("a", &["fd", "fe"]).unwrap(); | |
println!("Found: {:?}", data); | |
Ok(()) | |
} | |
fn main() { | |
// at this point the errors are fatal, let's just fail hard. | |
match do_redis_code() { | |
Err(err) => { | |
println!("Could not execute example:"); | |
println!(" {}: {}", err.category(), err.description()); | |
} | |
Ok(()) => {} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment