Exemple #1
0
        public void TestNearNamedCacheInstancing()
        {
            IConfigurableCacheFactory ccf = CacheFactory.ConfigurableCacheFactory;

            IXmlDocument config = XmlHelper.LoadXml("assembly://Coherence.Tests/Tangosol.Resources/s4hc-near-cache-config.xml");

            ccf.Config = config;

            INamedCache cache = ccf.EnsureCache("dist-extend-direct");

            Assert.IsNotNull(cache);
            Assert.IsInstanceOf(typeof(NearCache), cache);

            NearCache nc = cache as NearCache;

            Assert.IsNotNull(nc);
            ICache      fc = nc.FrontCache;
            INamedCache bc = nc.BackCache;

            Assert.IsNotNull(fc);
            Assert.IsNotNull(bc);

            Assert.IsInstanceOf(typeof(SafeNamedCache), nc.BackCache);
            Assert.IsInstanceOf(typeof(LocalNamedCache), nc.FrontCache);

            SafeNamedCache sc = nc.BackCache as SafeNamedCache;

            Assert.IsNotNull(sc);
            Assert.AreEqual(sc.CacheName, "dist-extend-direct");
            Assert.IsInstanceOf(typeof(RemoteNamedCache), sc.NamedCache);
            RemoteNamedCache rc = sc.NamedCache as RemoteNamedCache;

            Assert.IsNotNull(rc);
            Assert.AreEqual(rc.CacheName, sc.CacheName);

            LocalNamedCache lnc = nc.FrontCache as LocalNamedCache;

            Assert.IsNotNull(lnc);
            LocalCache lc = lnc.LocalCache;

            Assert.AreEqual(lc.ExpiryDelay, LocalCache.DEFAULT_EXPIRE);
            Assert.AreEqual(lc.FlushDelay, 0);
            Assert.AreEqual(lc.HighUnits, LocalCache.DEFAULT_UNITS);
            Assert.AreEqual(lc.CalculatorType, LocalCache.UnitCalculatorType.Fixed);
            Assert.AreEqual(lc.EvictionType, LocalCache.EvictionPolicyType.Hybrid);

            CacheFactory.Shutdown();
        }
 /// <summary>
 /// Initializes a new version of the <see cref="HDictionaryWithCache{TKey,TValue}"/> class.
 /// </summary>
 /// <param name="name">The unique name of the object.</param>
 /// <param name="cluster">A cluster.</param>
 /// <param name="serializationService">A serialization service.</param>
 /// <param name="lockReferenceIdSequence">A lock reference identifiers sequence.</param>
 /// <param name="cache">A cache.</param>
 /// <param name="loggerFactory">A logger factory.</param>
 public HDictionaryWithCache(string name, DistributedObjectFactory factory, Cluster cluster, ISerializationService serializationService, ISequence <long> lockReferenceIdSequence, NearCache <TValue> cache, ILoggerFactory loggerFactory)
     : base(name, factory, cluster, serializationService, lockReferenceIdSequence, loggerFactory)
 {
     _cache = cache;
 }