(二)在.net中如何使用Memcached
生活随笔
收集整理的這篇文章主要介紹了
(二)在.net中如何使用Memcached
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
Step1:第一步當(dāng)然是下載Memcached for c# API,
將這幾個dll引用到項目中去
?
step2:上代碼:
1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Web; 5 using System.Web.Mvc; 6 using Memcached.ClientLibrary; 7 8 namespace MvcDemo.Controllers 9 { 10 public class MemCachedController : Controller 11 { 12 // 13 // GET: /MemCached/ 14 15 public ActionResult Index() 16 { 17 18 string[] servers = { "172.16.200.67:41211" }; 19 SockIOPool pool = SockIOPool.GetInstance("test"); 20 pool.SetServers(servers); 21 pool.Initialize(); 22 MemcachedClient memClient = new MemcachedClient(); 23 memClient.PoolName = "test"; 24 memClient.EnableCompression = false; 25 bool b= memClient.Set("k2", "lixiaofei",DateTime.Now.AddMinutes(2)); 26 ViewBag.Name= memClient.Get("k2"); 27 return Content(ViewBag.Name); 28 } 29 30 } 31 } View Code?
轉(zhuǎn)載于:https://www.cnblogs.com/lxf1117/p/4047876.html
總結(jié)
以上是生活随笔為你收集整理的(二)在.net中如何使用Memcached的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: (软件工程复习核心重点)第五章详细设计-
- 下一篇: cvThreshold()函数理解