Преглед на файлове

Move first main.rs to example/hello-redis.rs

Hamid Ghadyani преди 8 месеца
родител
ревизия
a678c3bc4c
променени са 1 файла, в които са добавени 17 реда и са изтрити 0 реда
  1. 17 0
      examples/hello-redis.rs

+ 17 - 0
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(())
+}