コード例 #1
0
        public void TestEverySet(string cacheKey)
        {
            bool   state          = false;
            string methodCacheKey = null;
            var    cacheValue     = new CacheTest(1);

            methodCacheKey = cacheKey + "Add_Key_Value";
            state          = this.cacheClient.Add(methodCacheKey, cacheValue);
            log.DebugFormat("this.cacheClient.Add({0}, {1}): {2}", methodCacheKey, cacheValue.Value, state);
            TestGets(methodCacheKey);

            methodCacheKey = cacheKey + "Add_Key_Value_Date";
            state          = this.cacheClient.Add(methodCacheKey, cacheValue, DateTime.Now.AddDays(1));
            log.DebugFormat("this.cacheClient.Add({0}, {1}, 1Day): {2}", methodCacheKey, cacheValue.Value, state);
            TestGets(methodCacheKey);

            methodCacheKey = cacheKey + "Set_Key_Value";
            state          = this.cacheClient.Set(methodCacheKey, cacheValue);
            log.DebugFormat("this.cacheClient.Add({0}, {1}, 1Day): {2}", methodCacheKey, cacheValue.Value, state);
            TestGets(methodCacheKey);

            methodCacheKey = cacheKey + "Set_Key_Value_Date";
            state          = this.cacheClient.Set(methodCacheKey, cacheValue, DateTime.Now.AddDays(1));
            log.DebugFormat("this.cacheClient.Add({0}, {1}, 1Day): {2}", methodCacheKey, cacheValue.Value, state);
            TestGets(methodCacheKey);

            methodCacheKey = cacheKey + "Set_Key_Value_Date";
            state          = this.cacheClient.Set(methodCacheKey, cacheValue, DateTime.Now.AddDays(1));
            log.DebugFormat("this.cacheClient.Add({0}, {1}, 1Day): {2}", methodCacheKey, cacheValue.Value, state);
            TestGets(methodCacheKey);
        }
コード例 #2
0
        public void CacheSet(string cacheKey)
        {
            ClearCacheIfExists(cacheKey);

            var result = new CacheTest(1);

            var state = this.cacheClient.Set(cacheKey, result, DateTime.Now.AddMonths(1));

            Assert.That(state, Is.True);

            var cacheResult = this.cacheClient.Get<CacheTest>(cacheKey);

            Assert.That(cacheResult, Is.Not.Null);
            Assert.That(cacheResult.Value, Is.EqualTo(1));

            result = new CacheTest(2);
            state = this.cacheClient.Set(cacheKey, result);

            Assert.That(state, Is.True);

            cacheResult = this.cacheClient.Get<CacheTest>(cacheKey);

            Assert.That(cacheResult, Is.Not.Null);
            Assert.That(cacheResult.Value, Is.EqualTo(2)); //should not have changed.
        }
コード例 #3
0
        public void CacheSet(string cacheKey)
        {
            ClearCacheIfExists(cacheKey);

            var result = new CacheTest(1);

            var state = this.cacheClient.Set(cacheKey, result, DateTime.Now.AddMonths(1));

            Assert.That(state, Is.True);

            var cacheResult = this.cacheClient.Get <CacheTest>(cacheKey);

            Assert.That(cacheResult, Is.Not.Null);
            Assert.That(cacheResult.Value, Is.EqualTo(1));

            result = new CacheTest(2);
            state  = this.cacheClient.Set(cacheKey, result);

            Assert.That(state, Is.True);

            cacheResult = this.cacheClient.Get <CacheTest>(cacheKey);

            Assert.That(cacheResult, Is.Not.Null);
            Assert.That(cacheResult.Value, Is.EqualTo(2));             //should not have changed.
        }
コード例 #4
0
        public void TestEverySet(string cacheKey)
        {
            bool state = false;
            string methodCacheKey = null;
            var cacheValue = new CacheTest(1);

            methodCacheKey = cacheKey + "Add_Key_Value";
            state = this.cacheClient.Add(methodCacheKey, cacheValue);
            log.DebugFormat("this.cacheClient.Add({0}, {1}): {2}", methodCacheKey, cacheValue.Value, state);
            TestGets(methodCacheKey);

            methodCacheKey = cacheKey + "Add_Key_Value_Date";
            state = this.cacheClient.Add(methodCacheKey, cacheValue, DateTime.Now.AddDays(1));
            log.DebugFormat("this.cacheClient.Add({0}, {1}, 1Day): {2}", methodCacheKey, cacheValue.Value, state);
            TestGets(methodCacheKey);

            methodCacheKey = cacheKey + "Set_Key_Value";
            state = this.cacheClient.Set(methodCacheKey, cacheValue);
            log.DebugFormat("this.cacheClient.Add({0}, {1}, 1Day): {2}", methodCacheKey, cacheValue.Value, state);
            TestGets(methodCacheKey);

            methodCacheKey = cacheKey + "Set_Key_Value_Date";
            state = this.cacheClient.Set(methodCacheKey, cacheValue, DateTime.Now.AddDays(1));
            log.DebugFormat("this.cacheClient.Add({0}, {1}, 1Day): {2}", methodCacheKey, cacheValue.Value, state);
            TestGets(methodCacheKey);

            methodCacheKey = cacheKey + "Set_Key_Value_Date";
            state = this.cacheClient.Set(methodCacheKey, cacheValue, DateTime.Now.AddDays(1));
            log.DebugFormat("this.cacheClient.Add({0}, {1}, 1Day): {2}", methodCacheKey, cacheValue.Value, state);
            TestGets(methodCacheKey);
        }