Search code examples
servicestackservicestack.redis

Making ServiceStack RedisSentinel use a RedisManagerPool instead of a PooledRedisClientManager


Using ServiceStack version 4.0.40.

I am trying get RedisSentinel to use the RedisManagerPool instead of the PooledRedisClientManager so it will allow clients above the client pool size.

I see this in the docs to set this...

sentinel.RedisManagerFactory = (master,slaves) => new RedisManagerPool(master);

I'm not sure how to use this. Do I pass in the master host name? What if I don't know which is master because of a previous failover? I can't sentinel.start() to find out which is master because it will start with the PooledRedisClientManager, which isn't what I want.

Or, do I pass in the sentinel hosts? RedisManagerPool takes a list of hosts, I can pass in the sentinel hosts, but I cannot set it to sentinel.RedisManagerFactory as RedisManagerFactory is not convertible to RedisManagerPool.

I think I am missing something simple here. Any help appreciated.

UPDATE

As per mythz's comment below, this isn't available in version 4.0.40 of ServiceStack. But you can use;

  sential.RedisManagerFactory.FactoryFn = (master, slaves) => new RedisManagerPool(master);

Thanks


Solution

  • This is literally the config you need to use to change RedisSentinel to use RedisManagerPool:

    sentinel.RedisManagerFactory = (master,slaves) => 
        new RedisManagerPool(master);
    

    You don’t need to pass anything else, the master host argument uses the lambda argument.