StackExchange.Redis - Configuration
欲連線至 Redis,需先設定 Configutaion,在 StackExchange.Redis 提供兩種設定方式,一種是用 ConfigurationOptions 物件直接宣告設定:
using StackExchange.Redis;
...
var configuration = new ConfigurationOptions()
{
EndPoints = {
{"localhost", 6379},
{"localhost", 6380}
},
Password = "LarryNung"
};
using (var conn = ConnectionMultiplexer.Connect(configuration))
{
...
}
...
一種是透過字串的方式設定:
using StackExchange.Redis;
...
var configuration = "localhost:6379,localhost:6380,password=LarryNung";
using (var conn = ConnectionMultiplexer.Connect(configuration))
{
...
}
...
如果不清楚有哪些可供設定,可參閱下表:
{% img /images/posts/ConfigurationInStackExchange.Redis/1.png %}
{% img /images/posts/ConfigurationInStackExchange.Redis/2.png %}