public void TestGetCorrentCacheValue() { ICache cache = new MemCache(); string text = cache.GetOrSet("text", () => "hello world", 1); Assert.AreEqual("hello world", text); }
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 }
public static Account GetAccount(string name) { return(MemCache.GetOrSet(name, 3 * 60, () => GetAccountFromDB(name))); }