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);
        }
Exemple #2
0
        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);
            }
        }
Exemple #3
0
 public bool TryPublishCacheItemUpdated(string key)
 => notifier.TryPublish(cache.Name, key, CacheItemActionTypes.Updated);