示例#1
0
        protected virtual CacheMethodTaken TryGetScopedInner <TValue>(String key, out ScopedValue <TValue> value)
        {
            var directives = CacheDirectives.CurrentScope;

            if (!directives.Method.HasFlag(CacheMethod.Get))
            {
                value = default;
                return(CacheMethodTaken.None);
            }

            if (InnerCache.Get(key, regionName: null) is ScopedValue <TValue> scopedValue &&
                directives.IsInScope(scopedValue))
            {
                value = scopedValue;
                return(CacheMethodTaken.Get);
            }

            value = default;
            return(CacheMethodTaken.GetMiss);
        }
示例#2
0
 public CacheMethodTaken TryGetScoped <TValue>(String key, out ScopedValue <TValue> value)
 {
     return(TryGetScopedInner(key, out value));
 }
示例#3
0
 public CacheMethodTaken SetScoped <TValue>(String key, ScopedValue <TValue> scopedValue)
 => SetScoped(key, scopedValue.Value, scopedValue.ValueTimestamp);
示例#4
0
 public BusyService()
 {
     this.isBusy = new ScopedValue <bool>();
     this.isBusy.ValueStarted += OnBusyStarted;
     this.isBusy.ValueEnded   += OnBusyEnded;
 }
示例#5
0
 public Service1(ScopedValue scopedValue) => ScopedValue = scopedValue;
示例#6
0
 public CacheMethodTaken TryGetScoped<TValue>(string key, out ScopedValue<TValue> scopedValue)
 {
     return innerCache.TryGetScoped(key, out scopedValue);
 }
示例#7
0
 protected override CacheMethodTaken TryGetScopedInner<TValue>(string key, out ScopedValue<TValue> value)
 {
     var cacheMethodTaken = base.TryGetScopedInner(key, out value);
     if (cacheMethodTaken.HasFlag(CacheMethodTaken.Get)) hits++;
     if (cacheMethodTaken.HasFlag(CacheMethodTaken.GetMiss)) misses++;
     return cacheMethodTaken;
 }