Example #1
0
        public static CacheEntryOptions Clone(this CacheEntryOptions options)
        {
            var cloneOptions = Create();

            cloneOptions.CreatedUtc        = options.CreatedUtc;
            cloneOptions.ExpirationMode    = options.ExpirationMode;
            cloneOptions.ExpirationTimeout = options.ExpirationTimeout;

            return(cloneOptions);
        }
Example #2
0
        public static CacheEntryOptions Timeout(this CacheEntryOptions options, TimeSpan timeout)
        {
            if (timeout < TimeSpan.Zero)
            {
                timeout = TimeSpan.Zero;
            }

            options.ExpirationTimeout = timeout;

            return(options);
        }
Example #3
0
        public virtual Task SetAsync <TValue>(string key, TValue value, CacheEntryOptions options, string region)
        {
            if (string.IsNullOrEmpty(key))
            {
                throw new ArgumentNullException(nameof(key));
            }

            var cacheEntry = new CacheEntry <string, TValue>(key, region, value, options);

            return(SetAsync(cacheEntry));
        }
Example #4
0
        public virtual void Set <TValue>(TKey key, TValue value, CacheEntryOptions options, string region)
        {
            if (key == null)
            {
                throw new ArgumentNullException(nameof(key));
            }

            var cacheEntry = new CacheEntry <TKey, TValue>(key, region, value, options);

            Set(cacheEntry);
        }
Example #5
0
        public CacheEntry(TKey key, string region, TValue value, CacheEntryOptions options)
        {
            if (key == null)
            {
                throw new ArgumentNullException(nameof(key));
            }

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

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

            Key     = key;
            Region  = region;
            Value   = value;
            Options = options;
        }
Example #6
0
        public Task SetAsync <TValue>(string key, TValue value, CacheEntryOptions options, string region)
        {
            Set <TValue>(key, value, options, region);

            return(CompletedTask);
        }
Example #7
0
 public void Set <TValue>(string key, TValue value, CacheEntryOptions options, string region)
 {
     _localCacheProvider.Set <TValue>(key, value, options, region);
 }
Example #8
0
 public Task SetAsync <TValue>(string key, TValue value, CacheEntryOptions options)
 {
     return(SetAsync <TValue>(key, value, options, null));
 }
Example #9
0
 public void Set <TValue>(TKey key, TValue value, CacheEntryOptions options)
 {
     Set(key, value, options, null);
 }