CacheTower icon indicating copy to clipboard operation
CacheTower copied to clipboard

Manually Trigger Background Refresh

Open Turnerj opened this issue 2 years ago • 2 comments

There is one more thing I am wondering about. Is it possible to make a function that can manually refresh the data in the background? Same as with the staleAfter parameter but manually. cacheStack.RefreshValue(key, function?);

Originally posted by @muskara in https://github.com/TurnerSoftware/CacheTower/issues/187#issuecomment-908348841

Turnerj avatar Aug 31 '21 08:08 Turnerj

More-or-less, could expose it like so:

cacheStack.RefreshCache(cacheKey, valueFactory, cacheSettings);

public void RefreshCache(string cacheKey, Func<T, Task<T>> valueFactory, CacheSettings cacheSettings)
{
    _ = RefreshValueAsync(cacheKey, valueFactory, settings, CacheEntryStatus.Forced);
}

Turnerj avatar Jun 25 '22 15:06 Turnerj

Would need to create a second implementation that has Func<T, TContext, Task<T>> valueFactory for CacheStack<TContext> support though.

Turnerj avatar Jun 25 '22 15:06 Turnerj