本文整理汇总了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"));
});
}
示例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());
}
}
示例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"));
}
}