非常感谢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

   string[] serverlist = { "127.0.0.1:11211", "90.0.12.120:11211" };

             //初始化池
SockIOPool pool = SockIOPool.GetInstance();
pool.SetServers(serverlist); pool.InitConnections = ;
pool.MinConnections = ;
pool.MaxConnections = ; pool.SocketConnectTimeout = ;
pool.SocketTimeout = ; pool.MaintenanceSleep = ;
pool.Failover = true; pool.Nagle = false;
pool.Initialize(); // 获得客户端实例
MemcachedClient mc = new MemcachedClient();
mc.EnableCompression = false; Console.WriteLine("------------测 试-----------");
mc.Set("test1", "this is test"); //存储数据到缓存服务器,这里将字符串"my value"缓存,key 是"test" if (mc.KeyExists("test")) //测试缓存存在key为test的项目
{
Console.WriteLine("KEY为test的值正确写入");
Console.WriteLine("test的值是:"+mc.Get("test").ToString()); //在缓存中获取key为test的项目
}
else
{
Console.WriteLine("test not Exists");
} // Console.ReadLine();
var tt = mc.Get("test");
//mc.Delete("test"); //移除缓存中key为test的项目 if (mc.KeyExists("test"))
{
Console.WriteLine("test is Exists");
Console.WriteLine(mc.Get("test").ToString());
}
else
{
Console.WriteLine("值已删除");
}
//Console.ReadLine(); SockIOPool.GetInstance().Shutdown(); //关闭池, 关闭sockets

最新文章

  1. 第一次打开Lightroom时的基本设置
  2. MySQL 安装和启动服务,“本地计算机 上的 MySQL 服务启动后停止。某些服务在未由其他服务或程序使用时将自动停止。”
  3. [Word]将word文件中的软回车符[↓]替换为硬回车符
  4. 【HDU4419 Colourful Rectangle】 线段树面积并
  5. rpm安装rpm-package报错:Header signature NOKEY 和 error: Failed dependencies:
  6. 如何在OpenWRT环境下做开发
  7. JSTL和select标签的组合使用
  8. JDBC连接SQLServer的几种方式
  9. 局部敏感哈希(Locality-Sensitive Hashing, LSH)方法介绍
  10. BM算法详解
  11. 掌握好这23个Linux命令常用项
  12. Javascript时间戳和日期时间的相互转换
  13. 关于python format()用法详解
  14. IntelliJ IDEA 2017版 spring-boot2.0.2 自动配置Condition
  15. 手把手教你封装 Vue 组件并使用 NPM 发布
  16. 为什么说 LINQ 要胜过 SQL
  17. CSS相对定位|绝对定位(五)之z-index篇——张鑫旭
  18. 【BZOJ】1641: [Usaco2007 Nov]Cow Hurdles 奶牛跨栏(floyd)
  19. Linux buffer and cache
  20. RadioGroup多行显示

热门文章

  1. BZOJ_2813_奇妙的Fibonacci_线性筛
  2. python爬虫知识点总结(一)库的安装
  3. linux——boot空间不足
  4. 二叉树遍历入门 Lebal:research
  5. MySql介绍及优化(1)
  6. Linux rpm 命令参数使用…
  7. 使用Axis2方式发布webService的三种方式
  8. java继承使用的细节问题?
  9. java反射机制基础总结
  10. 3d全景图