Caching only a non-empty value.
Useful for get or create strategy
const cache = new Cache();
const getItemFunc = () => fetch(url).then((data) => {
return data.json(); // undefined
});
const item = await cache.addFull('foo', getItemFunc);
if (!item) {
await createItem(); // 'New item'
}
// somewhere else in the code
const item = await cache.addFull('foo', getItemFunc).then((resp) => {
console.log(resp); // 'New item'
});
Optional
props: CacheMatchProps<O>
Example
Example