
复制 1 using System; 2 using System.Collections.Generic; 4 namespace BeIT.MemCached 5 { 6 class Example 7 { 8 public static void Main(string[] args) 9 { 10 //通过配置文件初始化memcache实例 11 MemcachedClient cache = MemcachedClient.GetInstance("MyConfigFileCache"); 13 //编辑(可以模拟session操作,分布缓存20分钟) 14 cache.Set("name",式缓 "一线码农", DateTime.Now.AddMinutes(20)); 16 //获取 17 var result = cache.Get("name"); 19 Console.WriteLine("获取name的缓存数据为: " + result); 21 //删除 22 cache.Delete("name"); 24 Console.WriteLine("\n成功删除cache中name的免费源码下载数据"); 26 result = cache.Get("name"); 28 Console.WriteLine("\n再次获取cache中name的数据为:" + (result ?? "null") + "\n"); 30 //查看下memecahce的云服务器提供商运行情况 31 foreach (KeyValuePair<string, Dictionary<string, string>> host in cache.Status()) 32 { 33 Console.Out.WriteLine("Host: " + host.Key); 34 foreach (KeyValuePair<string, string> item in host.Value) 35 { 36 Console.Out.WriteLine("t" + item.Key + ": " + item.Value); 37 } 38 Console.Out.WriteLine(); 39 } 41 Console.Read(); 42 } 43 } 44 } 1.2.3.4.5.6.7.8.9.10.11.12.13.14.15.16.17.18.19.20.21.22.23.24.25.26.27.28.29.30.31.32.33.34.