本文整理汇总了C#中BookSleeve.RedisConnection.GetInfoImpl方法的典型用法代码示例。如果您正苦于以下问题:C# RedisConnection.GetInfoImpl方法的具体用法?C# RedisConnection.GetInfoImpl怎么用?C# RedisConnection.GetInfoImpl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BookSleeve.RedisConnection
的用法示例。
在下文中一共展示了RedisConnection.GetInfoImpl方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ConnectToNodes
private static void ConnectToNodes(TextWriter log, string tieBreakerKey, int syncTimeout, int keepAlive, bool allowAdmin, string clientName, string[] arr, List<RedisConnection> connections, out Task<string>[] infos, out Task<string>[] aux, AuxMode mode)
{
TraceWriteTime("Infos");
infos = new Task<string>[arr.Length];
aux = new Task<string>[arr.Length];
var opens = new Task[arr.Length];
for (int i = 0; i < arr.Length; i++)
{
var option = arr[i];
if (string.IsNullOrWhiteSpace(option)) continue;
RedisConnection conn = null;
try
{
var parts = option.Split(':');
if (parts.Length == 0) continue;
string host = parts[0].Trim();
int port = 6379, tmp;
if (parts.Length > 1 && int.TryParse(parts[1].Trim(), out tmp)) port = tmp;
conn = new RedisConnection(host, port, syncTimeout: syncTimeout, allowAdmin: allowAdmin);
conn.Name = clientName;
log.WriteLine("Opening connection to {0}:{1}...", host, port);
if (keepAlive >= 0) conn.SetKeepAlive(keepAlive);
opens[i] = conn.Open();
var info = conn.GetInfoImpl(null, false, false);
connections.Add(conn);
infos[i] = info;
switch (mode)
{
case AuxMode.TieBreakers:
if (tieBreakerKey != null)
{
aux[i] = conn.Strings.GetString(0, tieBreakerKey);
}
break;
case AuxMode.ClusterNodes:
aux[i] = conn.Cluster.GetNodes();
break;
}
}
catch (Exception ex)
{
if (conn == null)
{
log.WriteLine("Error parsing option \"{0}\": {1}", option, ex.Message);
}
else
{
log.WriteLine("Error connecting: {0}", ex.Message);
}
}
}
TraceWriteTime("Wait for infos");
RedisConnectionBase.Trace("select-create", "wait...");
var watch = new Stopwatch();
foreach (Task task in infos.Concat(aux).Concat(opens))
{
if (task != null)
{
try
{
int remaining = unchecked((int)(syncTimeout - watch.ElapsedMilliseconds));
if (remaining > 0) task.Wait(remaining);
}
catch { }
}
}
watch.Stop();
RedisConnectionBase.Trace("select-create", "complete");
}