示例#1
0
        private MemoryCacheEntryOptions GetMemoryCacheEntryOptions(CacheEntryOptions options)
        {
            if (options?.Expiration == null)
            {
                return(new MemoryCacheEntryOptions()
                       .SetSlidingExpiration(_cacheExpiration));
            }

            return(new MemoryCacheEntryOptions()
                   .SetSlidingExpiration(options.Expiration.Value));
        }
示例#2
0
        public Task SetAsync(object key, object value, CacheEntryOptions options = null)
        {
            Set(key, value, options);

            return(Task.CompletedTask);
        }
示例#3
0
        public void Set(object key, object value, CacheEntryOptions options = null)
        {
            var cacheEntryOptions = GetMemoryCacheEntryOptions(options);

            _memoryCache.Set(key, value, cacheEntryOptions);
        }