Example #1
0
        /// <summary>Constructor</summary>
        /// <param name="cacheName">name to identify the cache by</param>
        /// <param name="percentage">percentage of total java heap space used by this cache</param>
        /// <param name="expirationTime">time for an entry to expire in nanoseconds</param>
        public RetryCache(string cacheName, double percentage, long expirationTime)
        {
            int capacity = LightWeightGSet.ComputeCapacity(percentage, cacheName);

            capacity = capacity > 16 ? capacity : 16;
            this.set = new LightWeightCache <RetryCache.CacheEntry, RetryCache.CacheEntry>(capacity
                                                                                           , capacity, expirationTime, 0);
            this.expirationTime    = expirationTime;
            this.cacheName         = cacheName;
            this.retryCacheMetrics = RetryCacheMetrics.Create(this);
        }
Example #2
0
        public virtual void TestNames()
        {
            RetryCache cache = Org.Mockito.Mockito.Mock <RetryCache>();

            Org.Mockito.Mockito.When(cache.GetCacheName()).ThenReturn(cacheName);
            RetryCacheMetrics metrics = RetryCacheMetrics.Create(cache);

            metrics.IncrCacheHit();
            metrics.IncrCacheCleared();
            metrics.IncrCacheCleared();
            metrics.IncrCacheUpdated();
            metrics.IncrCacheUpdated();
            metrics.IncrCacheUpdated();
            CheckMetrics(1, 2, 3);
        }