use rustis::{
Result,
cache::Cache,
client::Client,
commands::{ClientTrackingOptions, StringCommands},
};
use std::time::Duration;
#[tokio::main]
async fn main() -> Result<()> {
let reader = Client::connect("127.0.0.1:6379").await?;
let writer = Client::connect("127.0.0.1:6379").await?;
writer.set("cached_key", "first").await?;
let cache = Cache::new(reader, 60, ClientTrackingOptions::default()).await?;
let value: String = cache.get("cached_key").await?;
println!("{value}");
let value: String = cache.get("cached_key").await?;
println!("{value}");
writer.set("cached_key", "second").await?;
tokio::time::sleep(Duration::from_millis(100)).await;
let value: String = cache.get("cached_key").await?;
println!("{value}");
Ok(())
}