本文整理汇总了C#中StackExchange.Redis.ConnectionMultiplexer.GetEndPoints方法的典型用法代码示例。如果您正苦于以下问题:C# ConnectionMultiplexer.GetEndPoints方法的具体用法?C# ConnectionMultiplexer.GetEndPoints怎么用?C# ConnectionMultiplexer.GetEndPoints使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StackExchange.Redis.ConnectionMultiplexer
的用法示例。
在下文中一共展示了ConnectionMultiplexer.GetEndPoints方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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");
}
示例2: RedisStorage
public RedisStorage(string connectionString, RedisStorageOptions options = null)
{
if (connectionString == null) throw new ArgumentNullException("connectionString");
if (options == null) options = new RedisStorageOptions();
_connectionMultiplexer = ConnectionMultiplexer.Connect(connectionString);
_invisibilityTimeout = options.InvisibilityTimeout;
var endpoint = _connectionMultiplexer.GetEndPoints()[0];
if (endpoint is IPEndPoint)
{
var ipEp = endpoint as IPEndPoint;
ConnectionString = string.Format("{0}:{1}", TryGetHostName(ipEp.Address), ipEp.Port);
}
else
{
var dnsEp = endpoint as DnsEndPoint;
ConnectionString = string.Format("{0}:{1}", dnsEp.Host, dnsEp.Port);
}
Db = options.Db;
if (Prefix != options.Prefix)
{
Prefix = options.Prefix;
}
identity = Guid.NewGuid().ToString();
}
示例3: RedisStorage
public RedisStorage(string connectionString, int db, TimeSpan invisibilityTimeout)
{
if (connectionString == null) throw new ArgumentNullException("connectionString");
if (invisibilityTimeout == null) throw new ArgumentNullException("invisibilityTimeout");
_connectionMultiplexer = ConnectionMultiplexer.Connect(connectionString);
_invisibilityTimeout = invisibilityTimeout;
var endpoint = _connectionMultiplexer.GetEndPoints()[0];
if (endpoint is IPEndPoint)
{
var ipEp = endpoint as IPEndPoint;
ConnectionString = string.Format("{0}:{1}", TryGetHostName(ipEp.Address), ipEp.Port);
}
else
{
var dnsEp = endpoint as DnsEndPoint;
ConnectionString = string.Format("{0}:{1}", dnsEp.Host, dnsEp.Port);
}
Db = db;
}
示例4: TryGetServer
internal static IServer TryGetServer(ConnectionMultiplexer muxer, bool checkConnected = true)
{
if (muxer != null)
{
var eps = muxer.GetEndPoints(true);
foreach (var ep in eps)
{
var server = muxer.GetServer(ep);
if (server.IsSlave) continue;
if (checkConnected && !server.IsConnected) continue;
// that'll do
return server;
}
}
return null;
}
示例5: GetHost
internal static string GetHost(ConnectionMultiplexer cache)
{
var endPoint = cache.GetEndPoints()[0];
var dnsEndPoint = endPoint as DnsEndPoint;
if (dnsEndPoint != null)
{
return String.Format("{0}:{1}", dnsEndPoint.Host, dnsEndPoint.Port);
}
var ipEndPoint = endPoint as IPEndPoint;
if (ipEndPoint != null)
{
return String.Format("{0}:{1}", ipEndPoint.Address, ipEndPoint.Port);
}
return endPoint.ToString();
}
示例6: GetServer
internal static IServer GetServer(ConnectionMultiplexer conn)
{
return conn.GetServer(conn.GetEndPoints()[0]);
}
示例7: FlushDatabase
/// <summary>
/// Flushes the database that the connection belongs to.
/// </summary>
/// <param name="connection">
/// The connection.
/// </param>
public void FlushDatabase(ConnectionMultiplexer connection)
{
EndPoint[] endPoints = connection.GetEndPoints();
foreach (var endPoint in endPoints)
{
connection.GetServer(endPoint).FlushDatabase(this.Db);
}
}
示例8: SetUp
public void SetUp()
{
redis = ConnectionMultiplexer.Connect("localhost,resolvedns=1,allowadmin=1,connectTimeout=10000");
endpoint = redis.GetEndPoints().First();
}