I am developing some web apis in .NET Core 2.2
The requirements brought us to the point where data is stored/cached/centralized within multiple redis storages (for the sake of easiness lets assume 2 redis servers).
That would be (as example)
- server 1 for the data protection
- server 2 for some other data
So far the data protection seems to work and it was configured using the connection multiplexer (which was added as singleton for reuse before hand) as suggested in the basic usage guide.
The relevant parts of StartUp.ConfigureServices
ConnectionMultiplexer cm = ConnectionMultiplexer.Connect("server1:6729");
services.AddSingleton<IConnectionMultiplexer>(cm);
services.AddDataProtection()
.SetApplicationName("myapp")
.PersitKeysToStackExchangeRedis(cm, "DataProtection-Keys");
The keys are stored as expected in the redis storage on server 1.
Now I need to integrate the second storage.
Can a ConnectionMultiplexer used to connect to two servers?
ConnectionMultiplexer cm = ConnectionMultiplexer.Connect("server1:6729;server2:6729"); //?
How to get the correct database pointing to the correct (either 1st or 2nd) server?