當前位置: 首頁>>代碼示例>>C#>>正文


C# PooledRedisClientManager.GetStats方法代碼示例

本文整理匯總了C#中ServiceStack.Redis.PooledRedisClientManager.GetStats方法的典型用法代碼示例。如果您正苦於以下問題:C# PooledRedisClientManager.GetStats方法的具體用法?C# PooledRedisClientManager.GetStats怎麽用?C# PooledRedisClientManager.GetStats使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在ServiceStack.Redis.PooledRedisClientManager的用法示例。


在下文中一共展示了PooledRedisClientManager.GetStats方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Can_recover_from_server_terminated_client_connection

        public void Can_recover_from_server_terminated_client_connection()
        {
            const int SleepHoldingClientMs = 5;
            const int SleepAfterReleasingClientMs = 0;
            const int loop = 1000;

            var admin = new RedisClient("localhost");
            admin.SetConfig("timeout", "0");
            var timeout = admin.GetConfig("timeout");
            timeout.Print("timeout: {0}");

            int remaining = loop;
            var stopwatch = Stopwatch.StartNew();

            var clientManager = new PooledRedisClientManager(new[] { "localhost" })
                {
                    
                };
            loop.Times(i =>
                {
                    ThreadPool.QueueUserWorkItem(x =>
                    {
                        try
                        {
                            using (var client = (RedisClient)clientManager.GetClient())
                            {
                                client.IncrementValue("key");
                                var val = client.Get<long>("key");
                                "#{0}, isConnected: {1}".Print(val, true); //client.IsSocketConnected()
                                Thread.Sleep(SleepHoldingClientMs);
                            }
                            Thread.Sleep(SleepAfterReleasingClientMs);
                        }
                        catch (Exception ex)
                        {
                            ex.Message.Print();
                        }
                        finally
                        {
                            remaining--;
                        }
                    });
                });

            while (remaining > 0)
            {
                Thread.Sleep(10);
            }
            "Elapsed time: {0}ms".Print(stopwatch.ElapsedMilliseconds);

            var managerStats = clientManager.GetStats();
            managerStats.PrintDump();
        }
開發者ID:jrmitch120,項目名稱:ServiceStack,代碼行數:53,代碼來源:RedisFailoverTests.cs


注:本文中的ServiceStack.Redis.PooledRedisClientManager.GetStats方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。