public async ValueTask <T> GetOrSetAsync <T>(string cacheKey, Func <T, TContext, Task <T> > getter, CacheSettings settings)
        {
            ThrowIfDisposed();

            if (cacheKey == null)
            {
                throw new ArgumentNullException(nameof(cacheKey));
            }

            if (getter == null)
            {
                throw new ArgumentNullException(nameof(getter));
            }

            return(await GetOrSetAsync <T>(cacheKey, async (old) =>
            {
                var context = ContextFactory();
                return await getter(old, context);
            }, settings));
        }
示例#2
0
 public DateTime GetStaleDate(CacheSettings cacheSettings)
 {
     return(Expiry - cacheSettings.TimeToLive + cacheSettings.StaleAfter);
 }