Попробуйте так
1. Свой CacheDependency
class CustomDependencyManager {
class CustomDependency : CacheDependency {
public void Invalidate() {
NotifyDependencyChanged(this, EventArgs.Empty);
}
}
public static CustomDependencyManager Instance = new CustomDependencyManager();
private readonly ConcurrentDictionary<string, CustomDependency> dependencies = new ConcurrentDictionary<string, CustomDependency>();
private CustomDependency GetCacheDependencyInternal(string xxx) {
return dependencies.GetOrAdd(xxx, s => new CustomDependency());
}
public void Invalidate(string xxx) {
GetCacheDependencyInternal(xxx).Invalidate();
}
public CacheDependency For(string xxx) {
GetCacheDependencyInternal(xxx);
}
}
2. Когда нужно, сбрасываем кеш
Cache.Insert("prefix_"+xxx+"_"+yyyy, data, CustomDependencyManager.Instance.For(xxx), DateTime.Now.AddSeconds(1), Cache.NoSlidingExpiration, CacheItemPriority.High, null);
...
...
// Пора сбросить кеш
CustomDependencyManager.Instance.Invalidate(xxx);