private void EvictFromHandle(string key, string region, BaseCacheHandle <TCacheValue> handle)
        {
            if (Logger.IsEnabled(LogLevel.Debug))
            {
                Logger.LogDebug(
                    "Evicting '{0}:{1}' from handle '{2}'.",
                    region,
                    key,
                    handle.Configuration.Name);
            }

            bool result;

            if (string.IsNullOrWhiteSpace(region))
            {
                result = handle.Remove(key);
            }
            else
            {
                result = handle.Remove(key, region);
            }

            if (result)
            {
                handle.Stats.OnRemove(region);
            }
        }
        private void EvictFromHandle(string key, string region, BaseCacheHandle <TCacheValue> handle)
        {
            if (_logTrace)
            {
                Logger.LogTrace(
                    "Evict [{0}:{1}] from handle '{2}'.",
                    region,
                    key,
                    handle.Configuration.Name);
            }

            bool result;

            if (string.IsNullOrWhiteSpace(region))
            {
                result = handle.Remove(key);
            }
            else
            {
                result = handle.Remove(key, region);
            }

            if (result)
            {
                handle.Stats.OnRemove(region);
            }
        }
Esempio n. 3
0
        private static void AssertCacheHandleConfig <T>(BaseCacheHandle <T> handle, string name, ExpirationMode mode, TimeSpan timeout)
        {
            var cfg = handle.Configuration;

            cfg.Name.Should().Be(name);
            cfg.ExpirationMode.Should().Be(mode);
            cfg.ExpirationTimeout.Should().Be(timeout);
        }
        private static bool AddItemToHandle(CacheItem <TCacheValue> item, BaseCacheHandle <TCacheValue> handle)
        {
            if (handle.Add(item))
            {
                handle.Stats.OnAdd(item);
                return(true);
            }

            return(false);
        }
Esempio n. 5
0
        private static async Task <bool> AddItemToHandleAsync(CacheItem <TCacheValue> item, BaseCacheHandle <TCacheValue> handle)
        {
            if (await handle.AddAsync(item).ConfigureAwait(false))
            {
                handle.Stats.OnAdd(item);
                return(true);
            }

            return(false);
        }