コード例 #1
0
 public static void Set <TOuterKey, TInnerKey, TValue>(
     this ILocalCache <TOuterKey, TInnerKey, TValue> cache,
     TOuterKey outerKey,
     TInnerKey innerKey,
     TValue value,
     TimeSpan timeToLive)
 {
     cache.SetMany(outerKey, new[] { new KeyValuePair <TInnerKey, TValue>(innerKey, value) }, timeToLive);
 }
コード例 #2
0
        public void SetMany(ReadOnlySpan <KeyValuePair <TKey, TValue> > values, TimeSpan timeToLive)
        {
            Interlocked.Increment(ref SetManyExecutionCount);

            if (_throwExceptionOnNextAction)
            {
                _throwExceptionOnNextAction = false;
                throw new Exception();
            }

            _innerCache.SetMany(values, timeToLive);
        }
コード例 #3
0
        public void SetMany(ReadOnlySpan <KeyValuePair <TKey, TValue> > values, TimeSpan timeToLive)
        {
            var stopwatch = StopwatchStruct.StartNew();

            try
            {
                _innerCache.SetMany(values, timeToLive);

                OnSetManyCompletedSuccessfully(values, timeToLive, stopwatch.Elapsed);
            }
            catch (Exception ex)
            {
                OnSetManyException(values, timeToLive, stopwatch.Elapsed, ex, out var exceptionHandled);

                if (!exceptionHandled)
                {
                    throw;
                }
            }
        }