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

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

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

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