本文整理汇总了C#中ServiceStack.Redis.RedisClient.HGet方法的典型用法代码示例。如果您正苦于以下问题:C# RedisClient.HGet方法的具体用法?C# RedisClient.HGet怎么用?C# RedisClient.HGet使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ServiceStack.Redis.RedisClient
的用法示例。
在下文中一共展示了RedisClient.HGet方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FindWord
private static void FindWord(RedisClient client, string key)
{
if (client.HExists("dictionary", ToByteArray(key)) > 0)
{
var translation = IntoString(client.HGet("dictionary", ToByteArray(key)));
Console.WriteLine(translation);
}
}
示例2: FindEntryByBookName
public static void FindEntryByBookName(RedisClient redisIO, string bookName)
{
Console.WriteLine("Search");
Console.WriteLine(new string('-', Console.WindowWidth - 5));
string translation = StringExtensions.StringFromByteArray(redisIO.HGet("Dictonary", bookName.ToAsciiCharArray()));
Console.WriteLine("Book Name: {0}, Translation: {1}", bookName, translation);
}
示例3: FindTranslation
public static void FindTranslation(RedisClient client, string word)
{
if (client.HExists(wordHashStructure, word.ToAsciiCharArray()) == 0)
{
Console.WriteLine("Word does not exist in the dictionary.");
return;
}
var translation = Extensions.StringFromByteArray(client.HGet(wordHashStructure, word.ToAsciiCharArray()));
Console.WriteLine(word + ":" + translation);
}
示例4: ListAll
public static void ListAll(RedisClient client)
{
var keys = client.HKeys(wordHashStructure);
var stringifiedKeys = new List<string>();
foreach (var key in keys)
{
stringifiedKeys.Add(Extensions.StringFromByteArray(key));
}
foreach (var key in stringifiedKeys)
{
Console.WriteLine(key + " : " + Extensions.StringFromByteArray(client.HGet(wordHashStructure, key.ToAsciiCharArray())));
}
}
示例5: SreachWord
public static void SreachWord(RedisClient words)
{
Console.Write("Enter word for translation: ");
string searchedWord = Console.ReadLine().ToLower();
long countWords = words.HExists("words", Extensions.ToAsciiCharArray(searchedWord));
if (countWords > 0)
{
var translation = words.HGet("words", Extensions.ToAsciiCharArray(searchedWord));
Console.WriteLine("Word: {0}\nTranslation: {1}", searchedWord, Extensions.StringFromByteArray(translation));
}
else
{
Console.WriteLine("This word is not exist");
}
}
示例6: 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.");
}
}
}
示例7: ShowTranslation
private static void ShowTranslation(RedisClient client)
{
Console.WriteLine("Enter word");
string word = Console.ReadLine();
byte[] wordInBytes = Extensions.ToAsciiCharArray(word);
if (!string.IsNullOrWhiteSpace(word))
{
if (client.HExists(dictionary, wordInBytes) == 1)
{
byte[] translation = client.HGet(dictionary, wordInBytes);
Console.WriteLine("Translation of the word {0} is:", word);
Console.WriteLine(Extensions.StringFromByteArray(translation));
}
else
{
Console.WriteLine("There is no word {0}.", word);
}
}
else
{
Console.WriteLine("You enter null or empty string for word. Please try again.");
}
}
示例8: SearchItem
public static void SearchItem(RedisClient redisDictionaryClient)
{
Console.WriteLine("Enter word for search: ");
string searchedWord = Console.ReadLine();
var searchedItems = redisDictionaryClient.HGet(ColectionKey, searchedWord.ToAsciiCharArray());
Console.WriteLine("Translation: {0}\n", Extensions.StringFromByteArray(searchedItems));
}
示例9: GetTranslation
static string GetTranslation(RedisClient redisClient, string word)
{
if (redisClient.HExists(DictionaryStructure, Extensions.ToAsciiCharArray(word)) != 0)
{
return Extensions.StringFromByteArray(
redisClient.HGet(DictionaryStructure, Extensions.ToAsciiCharArray(word)));
}
return null;
}