public InMemoryCache(string region, TimeSpan? timeToLive, TimeSpan? timeToIdle)
        {
            if (string.IsNullOrEmpty(region))
            {
                throw new ArgumentNullException(nameof(region));
            }

            if (timeToLive.HasValue && timeToLive.Value.TotalMilliseconds <= 0)
            {
                throw new ArgumentException("TTL duration must be greater than zero.", nameof(timeToLive));
            }

            if (timeToIdle.HasValue && timeToIdle.Value.TotalMilliseconds <= 0)
            {
                throw new ArgumentException("TTI duration must be greater than zero.", nameof(timeToIdle));
            }

            this.cacheManager = new InMemoryCacheManager();
            this.region = region;
            this.timeToLive = timeToLive;
            this.timeToIdle = timeToIdle;

            this.accessCount = 0;
            this.hitCount = 0;
            this.missCount = 0;
        }
示例#2
0
        public InMemoryCache(string region, TimeSpan?timeToLive, TimeSpan?timeToIdle)
        {
            if (string.IsNullOrEmpty(region))
            {
                throw new ArgumentNullException(nameof(region));
            }

            if (timeToLive.HasValue && timeToLive.Value.TotalMilliseconds <= 0)
            {
                throw new ArgumentException("TTL duration must be greater than zero.", nameof(timeToLive));
            }

            if (timeToIdle.HasValue && timeToIdle.Value.TotalMilliseconds <= 0)
            {
                throw new ArgumentException("TTI duration must be greater than zero.", nameof(timeToIdle));
            }

            this.cacheManager = new InMemoryCacheManager();
            this.region       = region;
            this.timeToLive   = timeToLive;
            this.timeToIdle   = timeToIdle;

            this.accessCount = 0;
            this.hitCount    = 0;
            this.missCount   = 0;
        }
 public void Clear()
 {
     this.cacheManager.Dispose();
     this.cacheManager = new InMemoryCacheManager();
 }
示例#4
0
 public void Clear()
 {
     this.cacheManager.Dispose();
     this.cacheManager = new InMemoryCacheManager();
 }