public async override Task Invoke(AspectContext context, AspectDelegate next) { var cachedRemoveConfigurationProvider = context.ServiceProvider.GetService <IOptionsMonitor <FilterCachedConfiguration> >(); var configCacheRemove = context.GetCacheRemoveConfigurationByMethodName(cachedRemoveConfigurationProvider.CurrentValue); if (configCacheRemove != null) { ResponseCacheService = context.ServiceProvider.GetService <IResponseCacheService>(); await ResponseCacheService .RemoveCachedResponseByNamesAsync(configCacheRemove.PatternMethodCachedName); } await next(context); }
/// <summary>Remove todas as chaves no redis</summary> /// <param name="cacheService">Serviço de cache</param> /// <param name="pattern">Padrão de nome das chaves a serem removidas</param> public static Task <long> RemoveAllByPatternAsync(this IResponseCacheService cacheService, string pattern) { var keys = cacheService.GetKeysByPattern(pattern, int.MaxValue); return(cacheService.RemoveCachedResponseByNamesAsync(keys.ToArray())); }