首页 > Web开发 > 详细

(二)在.net中如何使用Memcached

时间:2014-10-24 12:23:13      阅读:243      评论:0      收藏:0      [点我收藏+]

Step1:第一步当然是下载Memcached for c# API,

bubuko.com,布布扣

将这几个dll引用到项目中去

 

step2:上代码:

bubuko.com,布布扣
 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

 

(二)在.net中如何使用Memcached

原文:http://www.cnblogs.com/lxf1117/p/4047876.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!