Exemplo n.º 1
0
        public void TestNonexistingKeyInvalidate()
        {
            var cache = new MemCache <string, int>();

            Assert.IsFalse(cache.Invalidate("notexists"));

            cache.GetOrCreate("key", () => 0, TimeSpan.FromSeconds(1));
            Assert.IsTrue(cache.Invalidate("key"));
            Assert.IsFalse(cache.Invalidate("key"));
        }
Exemplo n.º 2
0
 public void Should_invalidate_cache()
 {
     _cache = new MemCache <int, string>(3, TimeSpan.MaxValue);
     _cache.Add(1, "a");
     _cache.Invalidate(1);
     Assert.Null(_cache.Get(1));
 }
Exemplo n.º 3
0
 public void Should_not_break_when_invalidating_non_existent_cache()
 {
     _cache = new MemCache <int, string>(3, TimeSpan.MaxValue);
     _cache.Invalidate(1);
     Assert.Null(_cache.Get(1));
 }