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


C# RedisClient.HGet方法代码示例

本文整理汇总了C#中RedisClient.HGet方法的典型用法代码示例。如果您正苦于以下问题:C# RedisClient.HGet方法的具体用法?C# RedisClient.HGet怎么用?C# RedisClient.HGet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在RedisClient的用法示例。


在下文中一共展示了RedisClient.HGet方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TestHGet

        public void TestHGet()
        {
            using(var mock = new MockConnector("localhost", 9999, "$5\r\nvalue\r\n"))
            using(var redis = new RedisClient(mock))
            {
                Assert.Equal("value", (string)redis.HGet("test", "field"));
                Assert.Equal("*3\r\n$4\r\nHGET\r\n$4\r\ntest\r\n$5\r\nfield\r\n", mock.GetMessage());
            }

            this.RealCall(redis =>
            {
                redis.HSet("test", "field", "value");
                Assert.Equal("value", (string)redis.HGet("test", "field"));
            });
        }
开发者ID:glorylee,项目名称:Aoite,代码行数:15,代码来源:RedisHashTests.cs

示例2: TestHGet

 public void TestHGet()
 {
     using (var mock = new FakeRedisSocket("$4\r\ntest\r\n"))
     using (var redis = new RedisClient(mock, new DnsEndPoint("fakehost", 9999)))
     {
         Assert.AreEqual("test", redis.HGet("test", "field"));
         Assert.AreEqual("*3\r\n$4\r\nHGET\r\n$4\r\ntest\r\n$5\r\nfield\r\n", mock.GetMessage());
     }
 }
开发者ID:DTBruce,项目名称:csredis,代码行数:9,代码来源:HashTests.cs

示例3: Main

    static void Main(string[] args)
    {
        // You may download Redis for Windows from https://github.com/MSOpenTech/redis/tree/2.6/bin/release
        // Start the Redis server by double-click on redis-server.exe
        // Start the Redis client by double-click on the redis-cli.exe
        // Then start the VS project to see the result on the Console

        using (var redisClient = new RedisClient())
        {
            // -----------------------------------------------------------
            // Adds words and their translations to our EnBg dictionary
            // ----------------------------------------------------------
            redisClient.HSet("EnBg", "tree", "дърво");
            redisClient.HSet("EnBg", "apple", "ябълка");
            redisClient.HSet("EnBg", "strawberry", "ягода");
            redisClient.HSet("EnBg", "blueberry", "боровинка");
            redisClient.HSet("EnBg", "peach", "праскова");
            redisClient.HSet("EnBg", "cherry", "череша");
            redisClient.HSet("EnBg", "grape", "грозде");

            // ---------------------------------------
            // List all words and their translations
            // ----------------------------------------
            string[] allWords = redisClient.HKeys("EnBg");

            Console.WriteLine("Word -> Translation");
            Console.WriteLine(new string('-', 30));
            for (int i = 0; i < allWords.Length; i++)
            {
                Console.WriteLine(allWords[i] + " -> " + redisClient.HGet("EnBg", allWords[i]));
            }
            Console.WriteLine();

            // ----------------------------------------
            // Find the translation of given word
            // ----------------------------------------
            Console.WriteLine("Find translation of a word");
            Console.WriteLine(new string('-', 30));
            Console.WriteLine("Translation of 'tree' is {0}", redisClient.HGet("EnBg", "tree"));
            Console.WriteLine("Translation of 'apple' is {0}", redisClient.HGet("EnBg", "apple"));
            Console.WriteLine("Translation of 'cherry' is {0}", redisClient.HGet("EnBg", "cherry"));
        }
    }
开发者ID:sabrie,项目名称:TelerikAcademy,代码行数:43,代码来源:DictionaryInRedis.cs


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