What does StackExchange.Redis do with the configur

2019-05-10 04:42发布

问题:

I'm looking at StackExchange.Redis and notice it has features for automatically determining which of the configured servers is master, and which are slaves.

I've not managed to spot what StackExchange actually does with the configured Masters/Slaves. Does it always run commands on Master, and only use configured Slaves for failover? Or is the answer more in-depth than that?

Any pointers appreciated!

回答1:

The key thing here is CommandFlags, a parameter on every method. By default, most are PreferMaster, however; note that write commands escalate to DemandMaster automatically. However, if you want to spread load, you can elect to push some read commands (preferably the expensive ones) to slaves via PreferSlave and DemandSlave.

The other things it let's you do is to switch master (promote to master) - although this is naturally more invasive.