当前位置: 首页>>代码示例>>C#>>正文


C# RedisClient.Ping方法代码示例

本文整理汇总了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;
        }
开发者ID:pavelsavara,项目名称:marias,代码行数:7,代码来源:RedisCacheService.cs

示例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());
     }
 }
开发者ID:glorylee,项目名称:Aoite,代码行数:9,代码来源:RedisConnectionTests.cs

示例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));
         }
     }
 }
开发者ID:richard-green,项目名称:csredis,代码行数:16,代码来源:RedisConnectionTests.cs

示例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', '-'));
                    }
//.........这里部分代码省略.........
开发者ID:pennyfx,项目名称:ctrader-to-redis-interface,代码行数:101,代码来源:cAlgoRedisClient.cs


注:本文中的RedisClient.Ping方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。