1
votes

I have multiple redis instances on my host (ports 6379, 6380). Currently I'm able to connect to the first instance (6379) using the setup below:

services.AddSingleton<IRedisClientsManager>(p =>
               new PooledRedisClientManager(Configuration.GetValue<long>("Redis:DatabaseId"), Configuration.GetValue<string>("127.0.0.1:6379"))
               {
                   ConnectTimeout = Configuration.GetValue<int>("Redis:connectTimeOut"),
                   IdleTimeOutSecs = Configuration.GetValue<int>("Redis:idleTimeOutSecs"),
                   PoolTimeout = Configuration.GetValue<int>("Redis:poolTimeOut")
               });

Given past experiences with Single Redis instance or Redis sentinel, i have decided to split mutually exclusive operations across multiple Redis instances to spread the work load

for example:

All Operation A will use the 6379 instance while All Operation B will use the 6380 instance

I have read ServiceStack documentation but didn't find any relevant information.

Any suggestion on how this can be achieved?

1

1 Answers

0
votes

As you've configured your PooledRedisClientManager with both primary and replica servers, when you resolve a read/write client, i.e:

using var redis = clientsManager.GetClient();

It will resolve the client connected to the primary server, whilst when resolving a readonly client:

using var redisReadOnly = clientsManager.GetReadOnlyClient();

It will resolve a client connected to one of the replicas instead.