本文整理汇总了C#中StackExchange.Redis.ConfigurationOptions类的典型用法代码示例。如果您正苦于以下问题:C# ConfigurationOptions类的具体用法?C# ConfigurationOptions怎么用?C# ConfigurationOptions使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ConfigurationOptions类属于StackExchange.Redis命名空间,在下文中一共展示了ConfigurationOptions类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UseRedisStorage
public static IGlobalConfiguration<RedisStorage> UseRedisStorage(this IGlobalConfiguration configuration, ConfigurationOptions Options, int db, string Prefix)
{
if (configuration == null) throw new ArgumentNullException("configuration");
if (Options == null) throw new ArgumentNullException("Options");
var storage = new RedisStorage(Options, db, Prefix);
return configuration.UseStorage(storage);
}
示例2: GetRedisConnection
private static ConnectionMultiplexer GetRedisConnection()
{
ConnectionMultiplexer connection;
string isLocal = ConfigurationManager.AppSettings["IsLocal"];
if (isLocal == "1")
{
connection = ConnectionMultiplexer.Connect(ConfigurationManager.AppSettings["RedisServer"]);
}
else
{
var options = new ConfigurationOptions();
options.EndPoints.Add(ConfigurationManager.AppSettings["RedisKeyDns"], 6380);
options.Ssl = true;
options.Password = ConfigurationManager.AppSettings["RedisPassword"];
options.AllowAdmin = true;
// necessary?
options.KeepAlive = 30;
options.ConnectTimeout = 15000;
options.SyncTimeout = 15000;
connection = ConnectionMultiplexer.Connect(options);
}
return connection;
}
示例3: WatcherManager
public WatcherManager(IEnumerable<WatchGroup> groups)
{
var groupList = groups.ToList();
var config = new ConfigurationOptions()
{
AllowAdmin = true,
};
foreach (var group in groupList)
{
config.EndPoints.Add(group.Master.EndPoint);
}
muxerInstance = ConnectionMultiplexer.Connect(config);
muxerInstance.ConnectionRestored += MuxerInstanceOnConnectionRestored;
foreach (var group in groupList)
{
var server = muxerInstance.GetServer(group.Master.EndPoint);
var epStr = server.EndPoint.ToString();
group.Master.Server = server;
group.Master.OnPing(TimeSpan.Zero);
Program.zkAdaptor.Identity(group.Master.EndPoint.ToString());
this.groups.Add(epStr, group);
redisInstancesDict.Add(epStr, group.Master);
}
}
示例4: CreateRedisCaches
private static IList<RedisConnection> CreateRedisCaches(ICollection<RedisLockEndPoint> redisEndPoints)
{
var caches = new List<RedisConnection>(redisEndPoints.Count);
foreach (var endPoint in redisEndPoints)
{
var configuration = new ConfigurationOptions
{
AbortOnConnectFail = false,
ConnectTimeout = endPoint.ConnectionTimeout ?? DefaultConnectionTimeout,
Ssl = endPoint.Ssl,
Password = endPoint.Password,
};
configuration.EndPoints.Add(endPoint.EndPoint);
caches.Add(new RedisConnection
{
ConnectionMultiplexer = ConnectionMultiplexer.Connect(configuration),
RedisDatabase = endPoint.RedisDatabase ?? DefaultRedisDatabase,
RedisKeyFormat = string.IsNullOrEmpty(endPoint.RedisKeyFormat) ? RedisLock.DefaultRedisKeyFormat : endPoint.RedisKeyFormat
});
}
return caches;
}
示例5: MainForm
public MainForm()
{
InitializeComponent();
var options = new ConfigurationOptions
{
ConnectTimeout = 5000,
SyncTimeout = 2000,
KeepAlive = 60,
EndPoints =
{
{Settings.Default.RedisHost, Settings.Default.RedisPort}
}
};
_redis = ConnectionMultiplexer.Connect(options);
var retries = 0;
while (!_redis.IsConnected)
{
var config = _redis.Configuration;
_redis.Dispose();
if (retries > 10)
{
MessageBox.Show(string.Format("Could not connect to the Redis server with configuration: {0}",
config));
Application.Exit();
}
_redis = ConnectionMultiplexer.Connect(options, Console.Out);
retries++;
}
_red = new LightControlSet(button_RedOn, button_RedOff, button_RedFlash, textBox_RedOnDuty, textBox_RedOffDuty, textBox_RedOffset, textBox_RedPower, button_RedApply);
_green = new LightControlSet(button_GreenOn, button_GreenOff, button_GreenFlash, textBox_GreenOnDuty, textBox_GreenOffDuty, textBox_GreenOffset, textBox_GreenPower, button_GreenApply);
_blueYellow = new LightControlSet(button_BlueOn, button_BlueOff, button_BlueFlash, textBox_BlueOnDuty, textBox_BlueOffDuty, textBox_BlueOffset, textBox_BluePower, button_BlueApply);
}
示例6: RedisUtils
static RedisUtils()
{
connection = new Lazy<ConnectionMultiplexer>(() =>
{
ExceptionDispatchInfo lastError = null;
ConfigurationOptions options = new ConfigurationOptions();
options.EndPoints.Add(GetHostAndPort());
options.AllowAdmin = true;
for (int i = 0; i < 5; i++)
{
try
{
var cnn = ConnectionMultiplexer.Connect(options);
if (cnn.IsConnected)
return cnn;
}
catch (Exception ex)
{
lastError = ExceptionDispatchInfo.Capture(ex);
Console.WriteLine(ex.Message);
Thread.Sleep(10);
}
}
lastError.Throw();
return null;
}
);
}
示例7: Can_start_slave
public async Task Can_start_slave()
{
using (var redis = new Redis())
using (var redis2 = new Redis())
{
////Arrange
// configure slave
var config = new ConfigurationOptions { AllowAdmin = true };
config.EndPoints.Add(redis.Endpoint);
config.EndPoints.Add(redis2.Endpoint);
using (var client = ConnectionMultiplexer.Connect(config))
await client.GetServer(redis.Endpoint).SlaveOfAsync(redis2.Endpoint);
// new single-node client
string actualValue;
using (var client = ConnectionMultiplexer.Connect(redis2.Endpoint.ToString()))
{
await client.GetDatabase().StringSetAsync("key", "value");
////Act
actualValue = await client.GetDatabase().StringGetAsync("key");
}
////Assert
Assert.That(actualValue, Is.EqualTo("value"));
}
}
示例8: RedisCacheConfig
static RedisCacheConfig()
{
string isLocal = WebConfigReader.Read("IsLocal");
if (isLocal == "1")
{
connection = ConnectionMultiplexer.Connect(WebConfigReader.Read("RedisServer"));
}
else
{
var options = new ConfigurationOptions();
options.EndPoints.Add(WebConfigReader.Read("RedisKeyDns"), 6380);
options.Ssl = true;
options.Password = WebConfigReader.Read("RedisPassword");
options.AllowAdmin = true;
// necessary?
options.KeepAlive = 30;
options.ConnectTimeout = 15000;
options.SyncTimeout = 15000;
connection = ConnectionMultiplexer.Connect(options);
}
}
示例9: RedisManager
public RedisManager()
{
var configurationOptions = new ConfigurationOptions {Password = "be61827946a5d7a6b7333875104d4a26"};
configurationOptions.EndPoints.Add(HostAndPort);
_redisConn = ConnectionMultiplexer.Connect(configurationOptions);
}
示例10: RedisTest
protected RedisTest()
{
var config = new ConfigurationOptions() { AllowAdmin = true };
config.EndPoints.Add(testHost, testPort);
Multiplexer = ConnectionMultiplexer.Connect(config);
Redis = GetFlushedRedis();
}
示例11: RedisCommon
public RedisCommon(string host="127.0.0.1", int port = 6379, string password = "") {
options = new ConfigurationOptions {
AllowAdmin = true,
EndPoints = {new IPEndPoint(IPAddress.Parse(host), port)},
Password = password
};
}
示例12: RedisAdaptor
public RedisAdaptor(List<EndPoint> endPoints)
{
var config = new ConfigurationOptions()
{
AllowAdmin = true,
};
foreach (var endPoint in endPoints)
{
config.EndPoints.Add(endPoint);
}
muxerInstance = ConnectionMultiplexer.Connect(config);
Handle = muxerInstance.GetDatabase();
var script = Load("update_multikeys_multifields.lua");
//todo a hack way .. to be changed later
foreach (var endPoint in muxerInstance.GetEndPoints())
{
var server = muxerInstance.GetServer(endPoint);
updateScriptSha = server.ScriptLoad(script);
}
Handle.StringSet("test", "111");
}
示例13: Connect
public static void Connect()
{
ConfigurationOptions options = new ConfigurationOptions();
options.EndPoints.Add("localhost:6379");
Connection = ConnectionMultiplexer.Connect(options);
}
示例14: Init
public static void Init(string sHost, int iPort, string sPassword)
{
CacheDatabase._Host = sHost;
CacheDatabase._Port = iPort;
CacheDatabase._Password = sPassword;
if (CacheDatabase._Password.Length > 0)
{
CacheDatabase._AuthRequired = true;
}
else
{
CacheDatabase._AuthRequired = false;
}
_oConectionOptions = new ConfigurationOptions();
if (CacheDatabase._AuthRequired)
{
CacheDatabase._oConectionOptions.Password = CacheDatabase._Password;
}
CacheDatabase._oConectionOptions.EndPoints.Add(CacheDatabase._Host + ":" + CacheDatabase._Port.ToString());
CacheDatabase._oCacheConnection = ConnectionMultiplexer.Connect(CacheDatabase._oConectionOptions);
CacheDatabase._oCommand = CacheDatabase._oCacheConnection.GetDatabase();
//Check to make sure the Key Exists and if not then set it to 0
if (!_oCommand.KeyExists(CacheDatabase._ObjectCounterKeyName))
{
CacheDatabase._oCommand.StringSet(CacheDatabase._ObjectCounterKeyName, 0);
}
}
示例15: RedisCache
/// <summary>
/// Initializes a new instance of the <see cref="RedisCache"/> class.
/// </summary>
/// <param name="configuration">The configuration.</param>
public RedisCache(ConfigurationOptions configuration)
{
if (RedisCache.connection == null)
{
try
{
connectionTask = ConnectionMultiplexer.ConnectAsync(configuration);
connectionTask.ContinueWith(t =>
{
lock (syncronizationObject)
{
if (RedisCache.connection == null)
RedisCache.connection = t.Result;
}
this.cache = RedisCache.connection.GetDatabase();
Trace.TraceInformation("Redis Cache Provider connection complete - Correlation Id = {0}", Trace.CorrelationManager.ActivityId);
});
}
catch (AggregateException age)
{
age.Handle(e =>
{
Trace.TraceError("Redis Cache Provider error - Correlation Id = {0}\n {1}\n {2}", Trace.CorrelationManager.ActivityId, e.Message, e.StackTrace);
return true;
});
}
catch (Exception ex)
{
Trace.TraceError("Redis Cache Provider exception - Correlation Id = {0}\n {1}\n {2}", Trace.CorrelationManager.ActivityId, ex.Message, ex.StackTrace);
}
}
}