日期:2014-05-18 浏览次数:20417 次
/// <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(); }
[MethodImpl(MethodImplOptions.Synchronized)] public void Shutdown() { if (Log.IsDebugEnabled) { Log.Debug(GetLocalizedString("start socket pool shutdown")); } if (_maintenanceThread != null && _maintenanceThread.IsRunning) StopMaintenanceThread(); _maintenanceThread = null; // 添加这一行 // ... }
------解决方案--------------------
帮顶。。。应该多去看看这方面的资料。。。学习了