Пример #1
0
        public void Touch()
        {
            _cache.Store("key", 123, Encoding.ASCII.GetBytes("12345"), new DateTime(1999, 1, 1));
            _cache.Touch("key", new DateTime(1999, 1, 1));

            Assert.AreEqual(2, _testObserver.Messages.Count);
            var storeNotification1 = GetNotification();

            Assert.IsInstanceOfType(storeNotification1, typeof(StoreNotification));
            var storeNotification2 = GetNotification(1);

            Assert.IsInstanceOfType(storeNotification2, typeof(TouchNotification));
        }
Пример #2
0
        public void TouchPreventsEvict()
        {
            _cache.Store("key1", 0, new byte[] { 0, 1, 2, 3, 4 }, DateTime.MaxValue);
            _cache.Store("key2", 0, new byte[] { 0, 1, 2, 3, 4 }, DateTime.MaxValue);
            _cache.Touch("key1", DateTime.MaxValue);

            _cache.Store("key3", 0, new byte[] { 0, 1, 2, 3, 4 }, DateTime.MaxValue);

            var keys = _cache.Keys.ToArray();

            Assert.AreEqual(2, keys.Length);
            Assert.IsTrue(keys.Contains("key1"));
            Assert.IsTrue(keys.Contains("key3"));
        }