Exemplo n.º 1
0
        public void TestGetCorrentCacheValue()
        {
            ICache cache = new MemCache();
            string text  = cache.GetOrSet("text", () => "hello world", 1);

            Assert.AreEqual("hello world", text);
        }
Exemplo n.º 2
0
        public void TestGetCacheWithExpireTime()
        {
            ICache cache = new MemCache();
            string text  = cache.GetOrSet("text", () => "hello world", 1);

            Thread.Sleep(63000);

            Assert.AreEqual("hello world", text); // should throw exception
        }
Exemplo n.º 3
0
 public static Account GetAccount(string name)
 {
     return(MemCache.GetOrSet(name, 3 * 60, () => GetAccountFromDB(name)));
 }