日期:2014-05-18  浏览次数:20417 次

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

/// <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;
           [color=#FF0000] pool.Initialize(); //第二次执行时 报另外一个进程在使用错误[/color]
            // 获得客户端实例
            MemcachedClient mc = new MemcachedClient();
            mc.EnableCompression = false;
            var mtc = mc.KeyExists("ShopShowTimes");
            var b = true;
            if (mtc)
            {
               //.......
            }
            else
            {
                mc.Set("ShopShowTimes", "ssss")
            }

            SockIOPool.GetInstance().Shutdown();
        }



如图上所述错误..求高手指点

------解决方案--------------------
帮顶 顺便学习
------解决方案--------------------
这个没遇到过,楼主多去看下他们官网资料,http://memcached.org/
------解决方案--------------------
试下修改SockIOPool.cs文件,在1086行增加一句把maintenance thread设为null
C# code

    [MethodImpl(MethodImplOptions.Synchronized)]
    public void Shutdown()
    {
        if (Log.IsDebugEnabled)
        {
            Log.Debug(GetLocalizedString("start socket pool shutdown"));
        }

        if (_maintenanceThread != null && _maintenanceThread.IsRunning)
            StopMaintenanceThread();


        _maintenanceThread = null; // 添加这一行

        // ...
    }

------解决方案--------------------
帮顶。。。应该多去看看这方面的资料。。。学习了