首页 > 代码库 > mencache的使用二
mencache的使用二
在这里说的是在C#中的使用,在C#中使用是需要引入驱动的,
可以在网上找,这里推荐一个链接http://sourceforge.net/projects/memcacheddotnet/
将Memcached.ClientLibrary;引入。另外的 commands.dll log4net.dll,ICSharpCode.SharpZipLib.dll
等,应该是被以来的,下面的代码显示,使用到的类只在Memcacahed.ClientLibrary程序集中。其中log4net是
memcache记录日志所用。
简单的代码如下:
using Memcached.ClientLibrary; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace memcache { class Program { static void Main(string[] args) { string[] server = { "10.21.160.31:11211"}; SockIOPool pool = SockIOPool.GetInstance();//在Memcached.ClientLibrary程序集里。 pool.SetServers(server); pool.InitConnections = 3; pool.MinConnections = 3; pool.MaxBusy = 5; pool.SocketConnectTimeout = 1000; pool.SocketTimeout = 3000; pool.MaintenanceSleep = 30; pool.Failover = true; pool.Nagle = false; pool.Initialize(); //获得客户端实例 MemcachedClient client = new MemcachedClient();//在Memcached.ClientLibrary程序集里 client.EnableCompression = false; client.Add("keyd1", "value12dfsdf", DateTime.Now.AddHours(1), 0); Console.WriteLine(client.Get("keyd1").ToString()); Console.ReadKey(); } } }
mencache的使用二
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。