Skip to content

Instantly share code, notes, and snippets.

@aramkoukia
Created January 7, 2018 00:05
Show Gist options
  • Save aramkoukia/096566cec1071a768b61440640f3ec61 to your computer and use it in GitHub Desktop.
Save aramkoukia/096566cec1071a768b61440640f3ec61 to your computer and use it in GitHub Desktop.
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