本文整理汇总了C#中RedisClient.Ping方法的典型用法代码示例。如果您正苦于以下问题:C# RedisClient.Ping方法的具体用法?C# RedisClient.Ping怎么用?C# RedisClient.Ping使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RedisClient
的用法示例。
在下文中一共展示了RedisClient.Ping方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RedisCacheService
static RedisCacheService()
{
Redis = new RedisClient("localhost");
string ping = Redis.Ping();
JsConfig.DateHandler = DateHandler.ISO8601;
}
示例2: PingTest
public void PingTest()
{
using(var mock = new MockConnector("localhost", 9999, "+PONG\r\n"))
using(var redis = new RedisClient(mock))
{
Assert.True(redis.Ping());
Assert.Equal("*1\r\n$4\r\nPING\r\n", mock.GetMessage());
}
}
示例3: TestQuit
public void TestQuit()
{
using (var redis = new RedisClient(Host, Port, 0))
{
Assert.AreEqual("OK", redis.Quit());
Assert.IsFalse(redis.Connected);
try
{
redis.Ping();
}
catch (Exception e)
{
Assert.IsInstanceOfType(e, typeof(InvalidOperationException));
}
}
}
示例4: OnStart
protected override void OnStart()
{
requirePayloads.Add("create_order", null);
requirePayloads.Add("cancel_order", null);
_redisClientOrderChannel = new RedisClient(redisHost, redisPort);
_redisClientQuote = new RedisClient(redisHost, redisPort);
_redisClientOrderChannel.SubscriptionReceived += (s, e) =>
{
this.Print("DEBUG: {0}", e.Message.Body);
try
{
var message = ParseMessage(e.Message.Body);
if (message == null) return;
switch ((string)message["cmd"])
{
case "create_order":
TradeResult result = CreateOrder((JObject)message["payload"]);
if (result != null)
{
HandleTradeResult(result, (JObject)message["payload"]);
}
break;
case "get_orders":
HandleGetOrders((JObject)message["payload"]);
break;
case "cancel_order":
HandleCloseOrder((JObject)message["payload"]);
break;
case "cancel_orders_all":
HandleCloseAllOrders((JObject)message["payload"]);
break;
case "get_positions":
HandleGetPositions((JObject)message["payload"]);
break;
case "close_position":
HandleClosePosition((JObject)message["payload"]);
break;
case "modify_position":
HandleModifyPosition((JObject)message["payload"]);
break;
case "get_time":
HandleGetTime((JObject)message["payload"]);
break;
default:
//this.Print("Unhandled message", (string)message["cmd"]);
break;
}
}
catch (Exception ex)
{
this.Print("Error processing request:" + ex.Message + "---" + ex.Source);
this.Print(ex.StackTrace.Replace('\n', '-'));
}
};
_redisClientOrderChannel.SubscriptionChanged += (s, e) =>
{
Console.WriteLine("There are now {0} open channels", e.Response.Count);
};
_redisClientOrderChannel.Connected += (s, e) =>
{
this.Print("_redisClient connected");
};
string ping = _redisClientOrderChannel.Ping();
this.Print(ping);
this.Print(_redisClientOrderChannel.Time());
new Task(() =>
{
this.Positions.Opened += (e) =>
{
try
{
this.Print("Position opened {0}", e.Position.Id);
// already handled
var key = _getPositionString(e.Position, "market_order");
if (alreadyHandledActions.ContainsKey(key))
{
alreadyHandledActions.Remove(key);
return;
}
HandlePositionOpened(e.Position);
}
catch (Exception ex)
{
this.Print("Error Positions.Opened:" + ex.Message + "---" + ex.Source);
this.Print(ex.StackTrace.Replace('\n', '-'));
}
//.........这里部分代码省略.........