use simple_async_cache_rs::AsyncCacheStore;
use std::time::Duration;
use tokio::time::sleep;
#[tokio::main]
async fn main() {
let store = AsyncCacheStore::new();
let cache = store.get("key_1".to_string(), 10).await;
let mut result = cache.lock().await;
match &mut *result {
Some(_d) => {
}
None => {
*result = Some("This is the first value for key_1.");
}
}
assert_eq!(
*store.get("key_1".to_string(), 0).await.lock().await,
Some("This is the first value for key_1.")
);
sleep(Duration::from_secs(15)).await;
assert_eq!(*store.get("key_1".to_string(), 0).await.lock().await, None);
}