Skip to content

Instantly share code, notes, and snippets.

@kuc-arc-f
Created June 25, 2025 01:14
Show Gist options
  • Save kuc-arc-f/6e1580252ba2c420127acfcf6ca21a72 to your computer and use it in GitHub Desktop.
Save kuc-arc-f/6e1580252ba2c420127acfcf6ca21a72 to your computer and use it in GitHub Desktop.
Rust + redis , example-1
[package]
name = "redis_test"
version = "0.1.0"
edition = "2021"
publish = false
[dependencies]
redis = "0.32"
use redis::{Commands, Connection, RedisResult};
fn main() -> RedisResult<()> {
// Redis に接続
let client = redis::Client::open("redis://127.0.0.1/")?;
let mut con = client.get_connection()?;
// set: キーと値を登録
let _: () = con.set("name", "Hello, Redis!")?;
println!("Key saved!");
// 確認のため get してみる
let val: String = con.get("name")?;
println!("my_key => {}", val);
Ok(())
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment