public static void Show() { for (int i = 0; i < 5; i++) { Console.WriteLine(GenericCache <int> .GetCache()); Thread.Sleep(10); Console.WriteLine(GenericCache <long> .GetCache()); Thread.Sleep(10); Console.WriteLine(GenericCache <DateTime> .GetCache()); Thread.Sleep(10); Console.WriteLine(GenericCache <string> .GetCache()); Thread.Sleep(10); Console.WriteLine(GenericCache <GenericCacheTest> .GetCache()); Thread.Sleep(10); } }
public static void Show() { for (int i = 0; i < 5; i++) { // 泛型缓存, 在首次调用的时候 初始化, // 后续直接调用缓存 比Dictionary based 快很多 Console.WriteLine(GenericCache <int> .GetCache()); Thread.Sleep(10); Console.WriteLine(GenericCache <long> .GetCache()); Thread.Sleep(10); Console.WriteLine(GenericCache <DateTime> .GetCache()); Thread.Sleep(10); Console.WriteLine(GenericCache <string> .GetCache()); Thread.Sleep(10); Console.WriteLine(GenericCache <GenericCacheTest> .GetCache()); Thread.Sleep(10); } }