You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
let value: Option<String> = cache_client.get(&key).await.ok();
if let Some(value) = value {
let item = serde_json::from_str::<Item>(&value).unwrap();
items.lock().unwrap().push(item);
} else {
warning!("MISSING CACHE KEY: {}", key);
}
Using Momento:
let get_response = cache_client
.get("cache_name", key)
.await
.map_err(|e| error!("ERROR - Momento - get_object {:?}", e))
.ok();
if let Some(get_response) = get_response {
let value: Option<String> = match get_response {
Get::Hit { value } => value.try_into().ok(),
Get::Miss => None,
};
if let Some(value) = value {
let item = serde_json::from_str::<MyItem>(&value)?;
items.push(item);
} else {
warning!("MISSING CACHE KEY: {}", key);
}
} else {
error!("MOMENTO get is null: {}", key);
}
Hi @ymwjbxxq, thanks for this issue. We don’t have a way right now to do the succinct type conversion. I agree with you that it would be a better experience.
Hello,
If I use Redis this is the syntax:
Using Momento:
Is there a way to convert types quickly? https://docs.rs/redis/latest/redis/#type-conversions
Thank you so much for your help.
The text was updated successfully, but these errors were encountered: