在应用程序中重用多路复用器
class Program
{
private static Lazy<ConnectionMultiplexer> _multiplexer =
new Lazy<ConnectionMultiplexer>(
() => ConnectionMultiplexer.Connect("localhost"),
LazyThreadSafetyMode.ExecutionAndPublication);
static void Main(string[] args)
{
IDatabase db1 = _multiplexer.Value.GetDatabase(1);
IDatabase db2 = _multiplexer.Value.GetDatabase(2);
}
}