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


C# RedisClient.Ping方法代碼示例

本文整理匯總了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.");
            }
        }
    }
開發者ID:nikolaynikolov,項目名稱:Telerik,代碼行數:44,代碼來源:RedisDictionaryDemo.cs

示例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());
        }
開發者ID:ServiceStackApps,項目名稱:RedisReact,代碼行數:17,代碼來源:RedisServices.cs

示例3: RedisDB

 private  RedisDB() 
 {
     _redisClient = new RedisClient();
     _redisClient.Ping();
 }
開發者ID:KrishnanSrinivasan,項目名稱:Disruptor-net-v1.1.0-With-WCF,代碼行數:5,代碼來源:RedisDB.cs

示例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());
        }
開發者ID:Refactoring,項目名稱:RedisReact,代碼行數:14,代碼來源:RedisServices.cs

示例5: GetPongForPing

        public void GetPongForPing()
        {
            var redisClient = new RedisClient();

            Assert.That(redisClient.Ping(), Is.True);
        }
開發者ID:mlnkrish,項目名稱:redis-sharp,代碼行數:6,代碼來源:PingCommandTest.cs


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