public bool TryRemove(TKey key, out TValue value)
        {
            var stopwatch = StopwatchStruct.StartNew();

            try
            {
                var removed = _innerCache.TryRemove(key, out value);

                OnTryRemoveCompletedSuccessfully(key, removed, value, stopwatch.Elapsed);

                return(removed);
            }
            catch (Exception ex)
            {
                OnTryRemoveException(key, stopwatch.Elapsed, ex, out var exceptionHandled);

                if (!exceptionHandled)
                {
                    throw;
                }

                value = default;
                return(false);
            }
        }
예제 #2
0
        public bool TryRemove(TKey key, out TValue value)
        {
            Interlocked.Increment(ref RemoveExecutionCount);

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

            return(_innerCache.TryRemove(key, out value));
        }