Beispiel #1
0
        public void FlushAll()
        {
            NameValueCollection settings = new NameValueCollection();
            settings.Add("ServerList", TestConfig.GetConfig().GetAppSetting("ServerList"));
            settings.Add("poolname", Guid.NewGuid().ToString());
            using (MemcachedCacheManager _mc = new MemcachedCacheManager(settings))
            {
                string keyBase = "testKey" + Guid.NewGuid().ToString();
                string obj = testString;

                //add with a day expirey
                _mc.Add(keyBase, obj);
                //WriteOutStats("After first add");
                string str = (string)_mc.GetData(keyBase);
                //WriteOutStats("After first get");
                Assert.IsTrue(str != null, "Test 1:Returned string should not be null");

                //check if it exists
                Assert.IsTrue(_mc.Contains(keyBase), "Test 2: Key should exist as it was just saved");

                //flush all keys
                _mc.Flush();
                str = (string)_mc.GetData(keyBase);
                Assert.IsTrue(str == null, "Test 3:Returned string should be null");
                Assert.IsTrue(!_mc.Contains(keyBase), "Test 4: Key should exist as it was just flushed");
            }


        }
Beispiel #2
0
        public void Delete()
        {
            NameValueCollection settings = new NameValueCollection();
            settings.Add("ServerList", TestConfig.GetConfig().GetAppSetting("ServerList"));
            settings.Add("poolname", Guid.NewGuid().ToString());
            using (MemcachedCacheManager _mc = new MemcachedCacheManager(settings))
            {
                string keyBase = "testKey" + Guid.NewGuid().ToString();
                string obj = testString;

                //add with a day expirey
                _mc.Add(keyBase, obj);
                string str = (string)_mc.GetData(keyBase);
                Assert.IsTrue(str != null);

                //check if it exists
                Assert.IsTrue(_mc.Contains(keyBase));

                //remove key            
                _mc.Remove(keyBase);
                str = (string)_mc.GetData(keyBase);
                Assert.IsTrue(str == null);
                Assert.IsTrue(!_mc.Contains(keyBase));
            }


        }