Beispiel #1
0
        public void NearCacheListenNoneInvokeTest()
        {
            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);

            IFilter         filter    = new GreaterFilter(IdentityExtractor.Instance, 199);
            IEntryProcessor processor = new ConditionalPut(filter, 204);

            nearcache.Invoke("Ivan", processor);
            Assert.AreEqual(4, nearcache["Ivan"]);
            Assert.AreEqual(4, nearcache.BackCache["Ivan"]);

            nearcache["Ivan"] = 200;
            nearcache.Invoke("Ivan", processor);
            Assert.AreEqual(200, nearcache["Ivan"]);
            Assert.AreEqual(204, nearcache.BackCache["Ivan"]);

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

            CacheFactory.Shutdown();
        }