本文整理匯總了C#中ServiceStack.Redis.RedisClient.Ping方法的典型用法代碼示例。如果您正苦於以下問題:C# RedisClient.Ping方法的具體用法?C# RedisClient.Ping怎麽用?C# RedisClient.Ping使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類ServiceStack.Redis.RedisClient
的用法示例。
在下文中一共展示了RedisClient.Ping方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: Main
private static void Main()
{
// The default console's font doesn't support Cyrillic letters.
// We should find a font with Unicode support and change the
// default font.
Console.OutputEncoding = Encoding.UTF8;
ConsoleHelper.SetConsoleFont(6);
string hashId = "dictionary";
string word = "humongous";
string synonym = "enormous";
using (var redisClient = new RedisClient("127.0.0.1:6379"))
{
if (redisClient.Ping())
{
long entriesCount = redisClient.HExists(hashId, StringUtils.ToAsciiCharArray(word));
if (entriesCount > 0)
{
Console.WriteLine("This word is already in the dictionary.");
}
else
{
redisClient.HSetNX(
hashId,
StringUtils.ToAsciiCharArray(word),
StringUtils.ToAsciiCharArray(synonym));
byte[] meaning = redisClient.HGet(hashId, StringUtils.ToAsciiCharArray(word));
Console.WriteLine(
"Word: {0}\nTranslation: {1}",
word,
StringUtils.StringFromByteArray(meaning));
redisClient.HDel(hashId, StringUtils.ToAsciiCharArray(word));
}
}
else
{
Console.WriteLine("The Redis server isn't started.");
}
}
}
示例2: Post
public object Post(ChangeConnection request)
{
var connString = "{0}:{1}?db={2}".Fmt(
request.Host ?? "127.0.0.1",
request.Port.GetValueOrDefault(6379),
request.Db.GetValueOrDefault(0));
if (!string.IsNullOrEmpty(request.Password))
connString += "&password=" + request.Password.UrlEncode();
var testConnection = new RedisClient(connString);
testConnection.Ping();
((IRedisFailover)TryResolve<IRedisClientsManager>()).FailoverTo(connString);
return Get(new GetConnection());
}
示例3: RedisDB
private RedisDB()
{
_redisClient = new RedisClient();
_redisClient.Ping();
}
示例4: Post
public object Post(ChangeConnection request)
{
var connString = "{0}:{1}?db={2}".Fmt(
request.Host ?? "127.0.0.1",
request.Port.GetValueOrDefault(6379),
request.Db.GetValueOrDefault(0));
var testConnection = new RedisClient(connString);
testConnection.Ping();
((IRedisFailover)RedisManager).FailoverTo(connString);
return Get(new GetConnection());
}
示例5: GetPongForPing
public void GetPongForPing()
{
var redisClient = new RedisClient();
Assert.That(redisClient.Ping(), Is.True);
}