示例#1
0
        public void OverwriteWithAbsoluteExpirationTest()
        {
            var key = "OverwriteWithAbsoluteExpirationTest";
            var val = Guid.NewGuid();

            IHttpRuntimeCacheProvider cacheProvider = new MongoCacheProvider();
            var result = cacheProvider.GetOrCreate <Guid>(key, () => val);

            Assert.AreEqual(result, val);

            var exist = cacheProvider.TryGet <Guid>(key, out val);

            Assert.IsTrue(exist);

            var val2 = Guid.NewGuid();

            cacheProvider.Overwrite <Guid>(key, val2, DateTime.UtcNow.AddSeconds(4D));

            Thread.Sleep(TimeSpan.FromSeconds(8D));
            Guid val3;

            exist = cacheProvider.TryGet <Guid>(key, out val3);
            Assert.IsFalse(exist);
            Assert.AreEqual(val3, Guid.Empty);
        }
        public void TryGetTest() {
            var key = "TryGetTest";
            Guid val;

            IHttpRuntimeCacheProvider cacheProvider = new MongoCacheProvider();
            var exist = cacheProvider.TryGet<Guid>(key, out val);
            Assert.IsFalse(exist);
            Assert.AreEqual(val, Guid.Empty);

            var val2 = Guid.NewGuid();
            cacheProvider.Overwrite(key, val2);
            exist = cacheProvider.TryGet<Guid>(key, out val);
            Assert.IsTrue(exist);
            Assert.AreEqual(val, val2);
        }
示例#3
0
        public void TryGetTest()
        {
            var  key = "TryGetTest";
            Guid val;

            IHttpRuntimeCacheProvider cacheProvider = new MongoCacheProvider();
            var exist = cacheProvider.TryGet <Guid>(key, out val);

            Assert.IsFalse(exist);
            Assert.AreEqual(val, Guid.Empty);

            var val2 = Guid.NewGuid();

            cacheProvider.Overwrite(key, val2);
            exist = cacheProvider.TryGet <Guid>(key, out val);
            Assert.IsTrue(exist);
            Assert.AreEqual(val, val2);
        }
示例#4
0
        public void OverwriteTest()
        {
            var key = "OverwriteTest";
            var val = Guid.NewGuid();

            IHttpRuntimeCacheProvider cacheProvider = new MongoCacheProvider();
            var result = cacheProvider.GetOrCreate <Guid>(key, () => val);

            Assert.AreEqual(result, val);

            var val2 = Guid.NewGuid();

            cacheProvider.Overwrite <Guid>(key, val2);

            Guid val3;
            var  exist = cacheProvider.TryGet <Guid>(key, out val3);

            Assert.IsTrue(exist);
            Assert.AreEqual(val3, val2);
        }
        public void OverwriteTest() {
            var key = "OverwriteTest";
            var val = Guid.NewGuid();

            IHttpRuntimeCacheProvider cacheProvider = new MongoCacheProvider();
            var result = cacheProvider.GetOrCreate<Guid>(key, () => val);
            Assert.AreEqual(result, val);

            var val2 = Guid.NewGuid();
            cacheProvider.Overwrite<Guid>(key, val2);

            Guid val3;
            var exist = cacheProvider.TryGet<Guid>(key, out val3);
            Assert.IsTrue(exist);
            Assert.AreEqual(val3, val2);
        }
        public void OverwriteWithAbsoluteExpirationTest() {
            var key = "OverwriteWithAbsoluteExpirationTest";
            var val = Guid.NewGuid();

            IHttpRuntimeCacheProvider cacheProvider = new MongoCacheProvider();
            var result = cacheProvider.GetOrCreate<Guid>(key, () => val);
            Assert.AreEqual(result, val);

            var exist = cacheProvider.TryGet<Guid>(key, out val);
            Assert.IsTrue(exist);

            var val2 = Guid.NewGuid();
            cacheProvider.Overwrite<Guid>(key, val2, DateTime.UtcNow.AddSeconds(4D));

            Thread.Sleep(TimeSpan.FromSeconds(8D));
            Guid val3;
            exist = cacheProvider.TryGet<Guid>(key, out val3);
            Assert.IsFalse(exist);
            Assert.AreEqual(val3, Guid.Empty);

        }