Not entirely sure if this isn't already possible, but I couldn't find out how to.
When I use a callback in the getOrElse() function to retrieve new data (and save it), I would like to be able to return the old/expired cache data (if any) whenever there was a problem fetching new data as a fallback. Something like this would be great:
cache.getOrElse(cacheKey, async (oldCache) => {
try {
return await fetchNewData();
}
catch(error) {
// return old cache if new data fetch fails
return oldCache;
}
});
Is this possible in some other way I'm not aware of?
Not entirely sure if this isn't already possible, but I couldn't find out how to.
When I use a callback in the
getOrElse()
function to retrieve new data (and save it), I would like to be able to return the old/expired cache data (if any) whenever there was a problem fetching new data as a fallback. Something like this would be great:Is this possible in some other way I'm not aware of?