Esempio n. 1
0
        public void TestCreateFromTemplate()
        {
            // Create a cache with random name
            var randomName = "template" + Guid.NewGuid();

            // Can't get non-existent cache with Cache method
            Assert.Throws <ArgumentException>(() => Ignite.GetCache <int, int>(randomName));
            Assert.IsFalse(Ignite.GetCacheNames().Contains(randomName));

            // Create cache and verify template setting.
            var cache = Ignite.CreateCache <int, int>(randomName);

            Assert.AreEqual(3, cache.GetConfiguration().Backups);
            Assert.IsTrue(Ignite.GetCacheNames().Contains(randomName));

            cache.Put(1, 10);
            Assert.AreEqual(10, cache.Get(1));

            // Can't create again
            Assert.Throws <IgniteException>(() => Ignite.CreateCache <int, int>(randomName));

            var cache0 = Ignite.GetCache <int, int>(randomName);

            Assert.AreEqual(10, cache0.Get(1));
        }
Esempio n. 2
0
        public void TestDynamicTemplate()
        {
            var template = new CacheConfiguration
            {
                Name               = "dynTempl*",
                Backups            = 7,
                RebalanceBatchSize = 1234
            };

            // Register template.
            Ignite.AddCacheConfiguration(template);

            // Double registration is allowed.
            Ignite.AddCacheConfiguration(template);

            var cache = Ignite.CreateCache <int, int>("dynTempl1");

            Assert.AreEqual(7, cache.GetConfiguration().Backups);
            Assert.AreEqual(1234, cache.GetConfiguration().RebalanceBatchSize);
        }