zoukankan      html  css  js  c++  java
  • 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();
            }
        }
    }
  • 相关阅读:
    5、依赖倒转原则
    4、开放-封闭原则
    3、单一职责原则
    2013年工作生活总结
    2、策略模式
    1、简单工厂模式
    Unity3D笔记四 基础知识概念
    PythonStudy——PyCharm使用技巧 Column Selection Mode(列选择模式)
    PythonStudy——函数对象的案例
    PythonStudy——函数嵌套定义 Function nesting definition
  • 原文地址:https://www.cnblogs.com/xiaoai123/p/6473137.html
Copyright © 2011-2022 走看看