Dynamically re-register a dependency at run-time?

We would like to be able to dynamically re-register a dependency at run-time to allow for dynamically swapping out a provider. For example, if our primary Redis cache provider is unavailable we would like to be able to change the connection in our configuration settings, signal the application and have it point to the new service provider in code without having to recycle the application pool. Is there a recommended strategy for handling this type of behavior? Do we just have a handler somewhere that unregisters the dependency that was initially set up in Global.asax and replaces it with the new dependency? Just want to know if there is a recommended approach for this type of thing.

The Container should be immutable after it’s created as it’s not ThreadSafe to mutate in multiple requests at runtime. For high availability Redis we recommend using a Redis Sentinel configuration that way the Redis Sentinel process monitors the master/slave instances and automatically handles the failover if master goes down which ServiceStack.Redis will pickup.

But if you want to replace the server manually you should instead call the FailoverTo APIs on the Redis Client Manager, e.g:

((IRedisFailover)container.TryResolve<IRedisClientsManager>())
.FailoverTo(newConnectionString);