public GetScopedResult <TValue> GetScoped <TValue>(String key, Func <ScopedValue <TValue> > getter) { CacheMethodTaken level2MethodTaken = CacheMethodTaken.None; var level1Result = this.level1.GetScoped(key, () => { var level2Result = this.level2.GetScoped(key, getter); level2MethodTaken = level2Result.MethodTaken; return(level2Result.ScopedValue); }); if (level2MethodTaken.HasFlag(CacheMethodTaken.Set) && this.policy.InvalidateLevel1OnLevel2Upsert) { level1Notifier.TryPublish(this.level1.Name, key, CacheItemActionTypes.Updated); } return(level1Result); }
public void Set <TValue>(String key, TValue value) { this.level2.Set(key, value); this.level1.Set(key, value); if (this.policy.InvalidateLevel1OnLevel2Upsert) { level1Notifier.TryPublish(this.level1.Name, key, CacheItemActionTypes.Updated); } }
public bool TryPublishCacheItemUpdated(string key) => notifier.TryPublish(cache.Name, key, CacheItemActionTypes.Updated);