use anyhow::Result;
use redis::AsyncCommands;
use redis_sentinel_pool::{SentinelPool, SentinelPoolConfig};
#[tokio::main]
async fn main() -> Result<()> {
tracing_subscriber::fmt()
.with_env_filter(tracing_subscriber::EnvFilter::from_default_env())
.init();
let cfg = SentinelPoolConfig::new(
vec![
"redis://127.0.0.1:26379",
"redis://127.0.0.1:26380",
"redis://127.0.0.1:26381",
],
"mymaster",
)
.max_size(16);
let pool = SentinelPool::new(cfg).await?;
{
let mut conn = pool.get().await?;
let _: () = conn.set("hello", "world").await?;
let val: String = conn.get("hello").await?;
println!("hello = {val}");
}
pool.shutdown().await;
Ok(())
}