Example #1
0
 private void ProcessCacheEvicts(ICollection <CacheOperationContext> contexts, bool beforeInvocation, object result)
 {
     foreach (var context in contexts)
     {
         CacheEvictOperation operation = (CacheEvictOperation)context.Metadata.Operation;
         if (beforeInvocation == operation.BeforeInvocation && context.IsConditionPassing(result))
         {
             performCacheEvict(context, operation, result);
         }
     }
 }
Example #2
0
        private void performCacheEvict(
            CacheOperationContext context, CacheEvictOperation operation, object result)
        {
            var key = "";

            foreach (var cache in context.Caches)
            {
                if (operation.CacheWide)
                {
                    cache.Clear();
                }
                else
                {
                    if (key.IsNullOrWhiteSpace())
                    {
                        key = context.GenerateKey(result);
                    }
                    cache.Evict(key);
                }
            }
        }