예제 #1
0
        public void BustCache(BustCacheAttribute attribute, IInvocation invocation)
        {
            var cacheKeyGenerator = _cacheKeyGenerators.FirstOrDefault(c => c.GetType() == attribute.CacheKeyGenerator) ?? new DefaultCacheKeyGenerator();

            var method = invocation.TargetType.GetMethod(attribute.MethodName ?? string.Empty);

            if (method == null)
            {
                var cacheKey = cacheKeyGenerator.GeneratePartialCacheKey(invocation.TargetType);
                _cache.RemoveAllStartingWith(cacheKey, attribute.CacheRegion);
            }
            else if (method.GetParameters().Any())
            {
                var cacheKey = cacheKeyGenerator.GeneratePartialCacheKey(method);
                _cache.RemoveAllStartingWith(cacheKey, attribute.CacheRegion);
            }
            else
            {
                var cacheKey = cacheKeyGenerator.GenerateCacheKey(method);
                _cache.Remove(cacheKey, attribute.CacheRegion);
            }
        }
        public void BustCache(BustCacheAttribute attribute, IInvocation invocation)
        {
            var cacheKeyGenerator = _cacheKeyGenerators.FirstOrDefault(c => c.GetType() == attribute.CacheKeyGenerator) ?? new DefaultCacheKeyGenerator();

            var method = invocation.TargetType.GetMethod(attribute.MethodName ?? string.Empty);

            if (method == null)
            {
                var cacheKey = cacheKeyGenerator.GeneratePartialCacheKey(invocation.TargetType);
                _cache.RemoveAllStartingWith(cacheKey, attribute.CacheRegion);
            }
            else if (method.GetParameters().Any())
            {
                var cacheKey = cacheKeyGenerator.GeneratePartialCacheKey(method);
                _cache.RemoveAllStartingWith(cacheKey, attribute.CacheRegion);
            }
            else
            {
                var cacheKey = cacheKeyGenerator.GenerateCacheKey(method);
                _cache.Remove(cacheKey, attribute.CacheRegion);
            }
        }