PooledRedisClientManager not releasing connections

喜你入骨 提交于 2019-12-03 08:37:41

Currently my biggest challenge is that client connections are not being closed.

You are using the 'PooledRedisClientManager' so my understanding is that the client connections should not be closed, just put into the pool for reuse. It looks like your pool size is 100 connections.

You can try using var mgr = new BasicRedisClientManager("localhost:6379") which should dispose of the client.

edit The below approach is not recommended - you should take a dependency on the IRedisClientsManager and wrap all redis client calls inside a using() block, otherwise you will be bitten by gremlins.

I've been having similar problems getting Windsor to play nicely with the PooledRedisClientsManager, in the end this seemed to work:

        container.Register(
            Component.For<IRedisClientsManager>()
                     .Instance(redisClients)
                     .LifestyleSingleton(),

            Component.For<IRedisClient>()
                     .UsingFactoryMethod(c => c.Resolve<IRedisClientsManager>().GetClient(),
                                        managedExternally: true));
    }

The managedExternally parameter tells Windsor to not try to apply decommissioning concerns to the IRedisClients and let the PooledRedisClientsManager handle recycling.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!