C#操作Redis Hash数据表

 1 /// <summary>
 2         /// Redis Hash
 3         /// </summary>
 4         public static void Redis_Hash()
 5         {
 6             RedisClient client = new RedisClient("127.0.0.1", 6379);
 7             //清空数据库缓存,慎用
 8             client.FlushAll();
 9             #region Hash
10             client.SetEntryInHash("Hash", "Name", "lily");
11             client.SetEntryInHash("Hash", "Age", "18");
12             client.SetEntryInHash("Hash", "Sex", "");
13             client.SetEntryInHash("Hash", "Address", "初中高中英语课本");
14 
15             //获取指定hash表中key的集合
16             List<string> HaskKey = client.GetHashKeys("Hash");
17             //然后便利当前key
18             foreach (string key in HaskKey)
19             {
20                 Console.WriteLine("Hash--Key:{0}", key);
21             }
22             //获取指定hash表中value的集合
23             List<string> HaskValue = client.GetHashValues("Hash");
24             //便利当前value
25             foreach (string value in HaskValue)
26             {
27                 Console.WriteLine("Hash--Value:{0}", value);
28             }
29 
30             //获取所有的key。
31             List<string> AllKey = client.GetAllKeys(); //获取所有的key。
32             foreach (string Key in AllKey)
33             {
34                 Console.WriteLine("AllKey--Key:{0}", Key);
35             }
36             #endregion
37         }

https://www.cnblogs.com/happygx/p/8416620.html

原文地址:https://www.cnblogs.com/youmingkuang/p/14276930.html