X-Git-Url: https://piware.de/gitweb/?p=learn-rust.git;a=blobdiff_plain;f=tokio-tutorial-mini-redis%2Fexamples%2Fhello-redis.rs;fp=tokio-tutorial-mini-redis%2Fexamples%2Fhello-redis.rs;h=a49865584dc70a67904e2e95634c4e5cbfe01a62;hp=0000000000000000000000000000000000000000;hb=098305fcbcb11b65b55f5969b346ba8fc77cd13c;hpb=bd9188aabf12e3071c68d738c614da69473a64d7 diff --git a/tokio-tutorial-mini-redis/examples/hello-redis.rs b/tokio-tutorial-mini-redis/examples/hello-redis.rs new file mode 100644 index 0000000..a498655 --- /dev/null +++ b/tokio-tutorial-mini-redis/examples/hello-redis.rs @@ -0,0 +1,17 @@ +use mini_redis::{client, Result}; + +#[tokio::main] +async fn main() -> Result<()> { + // Open a connection to the mini-redis address. + let mut client = client::connect("127.0.0.1:6379").await?; + + // Set the key "hello" with value "world" + client.set("hello", "world".into()).await?; + + // Get key "hello" + let result = client.get("hello").await?; + + println!("got value from the server; result={:?}", result); + + Ok(()) +}