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
#[cached(
key = "String",
time = 3600,
convert = r#"{ id }"#,
result = true,
)]
async fn get_item(id: String) -> Result<String> {
long_network_call().await
}
If get_item is called and there is a cached value but TTL has expired. I would still like the stale cached value to be returned immediately and then long_network_call is called in another thread to update the cached value, such that the NEXT call will get the fresh value.
This is important for making sure long_network_call stays off the critical path and doesn't affect performance of anything that needs get_item.
It also adds a way to use stale data if long_network_call fails. Following the idea that in many cases stale data is better than no data. I didn't see a way to do that either in this library.
Not sure I could think of a good config parameter name...
Maybe stale_immediately=true or refresh_async=true
The text was updated successfully, but these errors were encountered:
If I have a function like:
If
get_item
is called and there is a cached value but TTL has expired. I would still like the stale cached value to be returned immediately and thenlong_network_call
is called in another thread to update the cached value, such that the NEXT call will get the fresh value.This is important for making sure
long_network_call
stays off the critical path and doesn't affect performance of anything that needsget_item
.It also adds a way to use stale data if
long_network_call
fails. Following the idea that in many cases stale data is better than no data. I didn't see a way to do that either in this library.Not sure I could think of a good config parameter name...
Maybe
stale_immediately=true
orrefresh_async=true
The text was updated successfully, but these errors were encountered: