Created
January 7, 2018 00:05
-
-
Save aramkoukia/096566cec1071a768b61440640f3ec61 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using CacheManager.Core; | |
using System; | |
using Unity.Interception.PolicyInjection.Pipeline; | |
namespace CachingAspectOrientedImplemetation | |
{ | |
public class InvalidateCacheAttributeHandler : ICallHandler | |
{ | |
private BaseCacheManager<object> _cache; | |
public String KeyPrefix { get; set; } | |
public int Order { get; set; } | |
public InvalidateCacheAttributeHandler(string keyPrefix) | |
{ | |
var config = new ConfigurationBuilder() | |
.WithSystemRuntimeCacheHandle() | |
.Build(); | |
_cache = new BaseCacheManager<object>(config); | |
KeyPrefix = keyPrefix; | |
} | |
public IMethodReturn Invoke(IMethodInvocation input, GetNextHandlerDelegate getNext) | |
{ | |
var result = _cache.Remove(KeyPrefix); | |
IMethodReturn methodReturn = getNext()(input, getNext); | |
return methodReturn; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment