日期:2014-05-17  浏览次数:20431 次

asp.net 的Memcached用法【高分求解】

/// <summary>
        /// 统计浏览次数
        /// </summary>
        public void UpdateShowTimes()
        {
            string[] serverlist = { "10.0.0.131:11211", "10.0.0.132:11211" };
            //初始化池
            SockIOPool pool = SockIOPool.GetInstance();
            pool.SetServers(serverlist);

            pool.InitConnections = 3;
            pool.MinConnections = 3;
            pool.MaxConnections = 5;

            pool.SocketConnectTimeout = 1000;
            pool.SocketTimeout = 3000;

            pool.MaintenanceSleep = 30;
            pool.Failover = true;

            pool.Nagle = false;
            pool.Initialize(); //第二次执行时 报另外一个进程在使用错误
            // 获得客户端实例
            MemcachedClient mc = new MemcachedClient();
            mc.EnableCompression = false;
            var mtc = mc.KeyExists("ShopShowTimes");
            var b = true;
            if (mtc)
            {
               //.......
            }
            else
            {