public void LRUCacheRemoveTest()
        {
            LRUConcurrentDictionaryCache <Object, string> cache = new LRUConcurrentDictionaryCache <object, string>();
            Object obj1  = new object();
            Object obj12 = new object();
            Object obj13 = new object();
            Object obj2  = new object();
            Object obj22 = new object();
            Object obj3  = new object();
            Object obj4  = new object();

            cache.Set(obj1, "1");
            cache.Set(obj12, "1");
            cache.Set(obj13, "1");
            cache.Set(obj2, "2");
            cache.Set(obj22, "2");
            cache.Set(obj3, "3");
            cache.Set(obj4, "4");
            IEnumerable <Object> keys = cache.RemoveEntriesWithValues(new[] { "1", "2", "5" });
            string temp;
            int    size = cache.GetSize();

            Assert.IsTrue((!cache.TryGetValue(obj1, out temp)) &&
                          (!cache.TryGetValue(obj2, out temp)) && (size == 2) &&
                          (keys.Count() == 5));
            cache.RemoveEntriesWithKeys(new[] { obj3, obj4 });
            size = cache.GetSize();
            Assert.IsTrue(size == 0);
        }
        public void LRUCacheAddOrUpdate()
        {
            LRUConcurrentDictionaryCache <string, int> cache = new LRUConcurrentDictionaryCache <string, int>();

            cache.Set("test", 1);
            cache.Set("test", 2);

            Assert.IsTrue(cache.GetSize() == 1);
            int v;

            Assert.IsTrue(cache.TryGetValue("test", out v));
            Assert.IsTrue(v == 2);
        }
        public void LRUCacheUpdateValueMustNotRemoveOldest()
        {
            LRUConcurrentDictionaryCache <string, int> cache = new LRUConcurrentDictionaryCache <string, int>(3);

            cache.Set("a", 1);
            cache.Set("b", 2);
            cache.Set("c", 3);
            cache.Set("c", 4);
            int value;

            Assert.IsTrue(cache.TryGetValue("a", out value));
            Assert.IsTrue(value == 1);
        }
 private CallerChainImpl()
 {
     Joined = new LRUConcurrentDictionaryCache <string, AnySignedChain>();
 }