|
1234567891011121314151617181920212223242526272829303132 |
- using AspectCore.DynamicProxy;
- using Microsoft.Extensions.DependencyInjection;
- using Microsoft.Extensions.Logging;
- using HealthMonitor.Core.Pipeline;
- using HealthMonitor.Core.Pipeline.Aop;
- using HealthMonitor.Core.Pipeline.Aop.Query;
-
- namespace HealthMonitor.Core.Aop
- {
- [AttributeUsage(AttributeTargets.Method, Inherited = false)]
- public class QueryCacheInterceptorAttribute : AbstractInterceptorAttribute
- {
- public QueryCacheInterceptorAttribute() { }
-
- public async override Task Invoke(AspectContext context, AspectDelegate next)
- {
- var pipeContext = new CacheInterceptorContext()
- {
- AopContext = context,
- AopDelegate = next,
- Logger = context.ServiceProvider.GetService<ILogger<QueryCacheInterceptorAttribute>>()!
- };
-
- var pipeline = new AopCachePipeline();
- pipeline.AddValue(new AssertValidQueryValue());
- //pipeline.AddValue(new TryGetRefManagerValue());
- pipeline.AddValue(new GetOrInsertEntityCacheValue());
- pipeline.AddValue(new AopEndPipeValue());
- await pipeline.Start(pipeContext);
- }
- }
- }
|