Beispiel #1
0
        public void GlobalSetup()
        {
            Func <int, int> func = x => x;

            for (int i = 0; i < 6; i++)
            {
                dictionary.GetOrAdd(1, func);

                concurrentLru.GetOrAdd(i, func);
                fastConcurrentLru.GetOrAdd(i, func);
                concurrentTLru.GetOrAdd(i, func);
                fastConcurrentTLru.GetOrAdd(i, func);

                classicLru.GetOrAdd(i, func);
                stringKeys[i] = i.ToString();
                memoryCache.Set(stringKeys[i], "test", new CacheItemPolicy());
            }
        }
        public void ConcurrentTLru()
        {
            Func <int, int> func = x => x;

            for (int i = 0; i < sampleCount; i++)
            {
                concurrentTlru.GetOrAdd(samples[i], func);
            }
        }
        public void WhenItemIsNotExpiredItIsNotRemoved()
        {
            lru.GetOrAdd(1, valueFactory.Create);

            lru.TryGet(1, out var value).Should().BeTrue();
        }
        public void ConstructAddAndRetrieveWithDefaultCtorReturnsValue()
        {
            var x = new ConcurrentTLru <int, int>(3, TimeSpan.FromSeconds(1));

            x.GetOrAdd(1, k => k).Should().Be(1);
        }