Esempio n. 1
0
        public void TestClientOnlyPlatformCache()
        {
            var cache = _grid.CreateCache <int, int>(TestUtils.TestName);

            cache[1] = 2;

            var clientCache = _client.CreateNearCache <int, int>(cache.Name, new NearCacheConfiguration(),
                                                                 new PlatformCacheConfiguration());

            Assert.AreEqual(2, clientCache[1]);
            Assert.AreEqual(1, clientCache.GetLocalSize(CachePeekMode.Platform));

            var clientCache2 = _client.GetOrCreateNearCache <int, int>(cache.Name, new NearCacheConfiguration(),
                                                                       new PlatformCacheConfiguration());

            Assert.AreEqual(2, clientCache2[1]);
            Assert.AreEqual(1, clientCache2.GetLocalSize(CachePeekMode.Platform));

            var clientCache3 = _client.CreateCache <int, int>(new CacheConfiguration(cache.Name + "3"),
                                                              new NearCacheConfiguration(), new PlatformCacheConfiguration());

            clientCache3[1] = 2;
            Assert.AreEqual(2, clientCache3.LocalPeek(1, CachePeekMode.Platform));

            var clientCache4 = _client.GetOrCreateCache <int, int>(new CacheConfiguration(cache.Name + "4"),
                                                                   new NearCacheConfiguration(), new PlatformCacheConfiguration());

            clientCache4[1] = 2;
            Assert.AreEqual(2, clientCache4.LocalPeek(1, CachePeekMode.Platform));
        }
Esempio n. 2
0
        public void TestCreateNearCache()
        {
            const string cacheName = "dyn_cache";

            var cache = _grid.CreateCache <int, string>(cacheName);

            cache[1] = "1";

            var nearCache = _grid.CreateNearCache <int, string>(cacheName, new NearCacheConfiguration());

            Assert.AreEqual("1", nearCache[1]);

            // Create when exists
            nearCache = _grid.CreateNearCache <int, string>(cacheName, new NearCacheConfiguration());
            Assert.AreEqual("1", nearCache[1]);
        }
Esempio n. 3
0
        public void TestCreateNearCache(
            [Values(CacheMode.Partitioned, CacheMode.Replicated)]
            CacheMode cacheMode,
            [Values(CacheAtomicityMode.Atomic, CacheAtomicityMode.Transactional)]
            CacheAtomicityMode atomicityMode)
        {
            var cacheName = string.Format("dyn_cache_{0}_{1}", cacheMode, atomicityMode);

            var cfg = new CacheConfiguration(cacheName)
            {
                AtomicityMode = atomicityMode,
                CacheMode     = cacheMode
            };

            var cache = _grid.CreateCache <int, int>(cfg);

            cache[1] = 1;

            var nearCacheConfiguration = new NearCacheConfiguration();
            var nearCache = _client.CreateNearCache <int, int>(cacheName, nearCacheConfiguration);

            Assert.AreEqual(1, nearCache[1]);

            // Create when exists.
            nearCache = _client.CreateNearCache <int, int>(cacheName, nearCacheConfiguration);
            Assert.AreEqual(1, nearCache[1]);

            // Update entry.
            cache[1] = 2;
            TestUtils.WaitForTrueCondition(() => nearCache[1] == 2);

            // Update through near.
            nearCache[1] = 3;
            Assert.AreEqual(3, nearCache[1]);

            // Remove.
            cache.Remove(1);
            TestUtils.WaitForTrueCondition(() => !nearCache.ContainsKey(1));
        }
Esempio n. 4
0
 /** <inheritdoc /> */
 public ICache<TK, TV> CreateNearCache<TK, TV>(string name, NearCacheConfiguration configuration)
 {
     return _ignite.CreateNearCache<TK, TV>(name, configuration);
 }