Beispiel #1
0
        public void NearCacheListenNoneInvokeAllTest()
        {
            LocalNamedCache localcache = new LocalNamedCache();
            INamedCache     safecache  = CacheFactory.GetCache(CacheName);
            NearCache       nearcache  = new NearCache(localcache, safecache, CompositeCacheStrategyType.ListenNone);

            nearcache.Clear();

            Hashtable ht = new Hashtable();

            ht.Add("Aleks", 1);
            ht.Add("Ana", 2);
            ht.Add("Goran", 3);
            ht.Add("Ivan", 4);
            nearcache.InsertAll(ht);

            Hashtable htput = new Hashtable();

            htput.Add("Aleks", 195);
            htput.Add("Ana", 205);

            IFilter         filter    = new LessFilter(IdentityExtractor.Instance, 2);
            IEntryProcessor processor = new ConditionalPutAll(AlwaysFilter.Instance, htput);

            nearcache.InvokeAll(filter, processor);
            Assert.AreEqual(195, nearcache.BackCache["Aleks"]);
            Assert.AreEqual(2, nearcache.BackCache["Ana"]);

            nearcache.InvokeAll(htput.Keys, processor);
            Assert.AreEqual(205, nearcache.BackCache["Ana"]);

            nearcache.Clear();
            nearcache.Release();
            Assert.IsFalse(nearcache.IsActive);

            CacheFactory.Shutdown();
        }