You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

DeleteCacheInterceptorAttribute.cs 1.2KB

1234567891011121314151617181920212223242526272829303132
  1. using AspectCore.DynamicProxy;
  2. using Microsoft.Extensions.DependencyInjection;
  3. using Microsoft.Extensions.Logging;
  4. using HealthMonitor.Core.Pipeline;
  5. using HealthMonitor.Core.Pipeline.Aop;
  6. using HealthMonitor.Core.Pipeline.Aop.Delete;
  7. namespace HealthMonitor.Core.Aop
  8. {
  9. [AttributeUsage(AttributeTargets.Method, Inherited = false)]
  10. public class DeleteCacheInterceptorAttribute : AbstractInterceptorAttribute
  11. {
  12. public DeleteCacheInterceptorAttribute() { }
  13. public async override Task Invoke(AspectContext context, AspectDelegate next)
  14. {
  15. var pipeContext = new CacheInterceptorContext()
  16. {
  17. AopContext = context,
  18. AopDelegate = next,
  19. Logger = context.ServiceProvider.GetService<ILogger<DeleteCacheInterceptorAttribute>>()!
  20. };
  21. var pipeline = new AopCachePipeline();
  22. pipeline.AddValue(new AssertValidDeleteValue());
  23. //pipeline.AddValue(new TryRemoveRefManagerValue());
  24. pipeline.AddValue(new DeleteEntityCacheValue());
  25. pipeline.AddValue(new AopEndPipeValue());
  26. await pipeline.Start(pipeContext);
  27. }
  28. }
  29. }