国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

.netmemcache

2019-11-14 16:08:18
字體:
來源:轉載
供稿:網友

非常感謝csdn及冷月宮主讓我很快學會了.net操作 memcache 文章轉自:http://download.csdn.net/detail/e_wsq/4358982

C#存取Memcache的示例 1 將Commons.dll,ICSharpCode.SharpZipLib.dll,log4net.dll,Memcached.ClientLibrary.dll 等放到bin目錄 2 引用Memcached.ClientLibrary.dll

 1   string[] serverlist = { "127.0.0.1:11211", "90.0.12.120:11211" }; 2  3             //初始化池 4             SockIOPool pool = SockIOPool.GetInstance(); 5             pool.SetServers(serverlist); 6  7             pool.InitConnections = 3; 8             pool.MinConnections = 3; 9             pool.MaxConnections = 5;10 11             pool.SocketConnectTimeout = 1000;12             pool.SocketTimeout = 3000;13 14             pool.MaintenanceSleep = 30;15             pool.Failover = true;16 17             pool.Nagle = false;18             pool.Initialize();19 20             // 獲得客戶端實例21             MemcachedClient mc = new MemcachedClient();22             mc.EnableComPRession = false;23 24             Console.WriteLine("------------測   試-----------");25             mc.Set("test1", "this is test");  //存儲數據到緩存服務器,這里將字符串"my value"緩存,key 是"test"26 27             if (mc.KeyExists("test"))   //測試緩存存在key為test的項目28             {29                 Console.WriteLine("KEY為test的值正確寫入");30                 Console.WriteLine("test的值是:"+mc.Get("test").ToString());  //在緩存中獲取key為test的項目31             }32             else33             {34                 Console.WriteLine("test not Exists");35             }36 37            // Console.ReadLine();38             var tt = mc.Get("test");39             //mc.Delete("test");  //移除緩存中key為test的項目40            41             if (mc.KeyExists("test"))42             {43                 Console.WriteLine("test is Exists");44                 Console.WriteLine(mc.Get("test").ToString());45             }46             else47             {48                 Console.WriteLine("值已刪除");49             }50             //Console.ReadLine();51 52             SockIOPool.GetInstance().Shutdown();  //關閉池, 關閉sockets
View Code

 


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 茌平县| 江口县| 准格尔旗| 诸城市| 富蕴县| SHOW| 绥中县| 曲靖市| 来宾市| 崇明县| 垦利县| 长泰县| 新郑市| 同仁县| 广南县| 灵山县| 靖江市| 离岛区| 遂平县| 图木舒克市| 西林县| 山东| 垣曲县| 宜昌市| 鹤峰县| 星子县| 个旧市| 德保县| 资阳市| 康定县| 浠水县| 壶关县| 兰州市| 渑池县| 泽州县| 肥西县| 怀宁县| 邵东县| 慈利县| 长白| 宝清县|