public class CacheAttribute : MethodInterceptionAspect
{
public override void OnInvoke(MethodInterceptionArgs methodInterceptionArgs)
{
if ((methodInterceptionArgs.Method.Name == CacheAspectAction.Get.ToString())
//&& (Memory.Cache[cacheKey] != null)
)
{
// methodInterceptionArgs.ReturnValue = HttpRuntime.Cache[cacheKey];
return;
}
object returnVal = methodInterceptionArgs.Invoke(methodInterceptionArgs.Arguments);
ClanCache(cacheKeyBase, cacheKey);
if (returnVal != null)
//Memory.Cache.Insert(cacheKey, returnVal, null, expirationInformation.AbsoluteExpiration, expirationInformation.SlidingExpiration);
methodInterceptionArgs.ReturnValue = returnVal;
}
}
Как получить доступ к кэшу в памяти в ASP.NET Core из любого класса, включая аспект PostSharp? Например, мне нужно получить доступ к IMemoryCache в MethodInterceptionAspect
и OnMethodBoundaryAspect
.