C#操作Redis Listリスト
8546 ワード
1 ///
2 /// Redis
3 ///
4 public static void Redis_List()
5 {
6 RedisClient client = new RedisClient("127.0.0.1", 6379);
7 // ,
8 client.FlushAll();
9
10 /*
11 * list , push,pop, , key 。
12 * Redis list string 。 push,pop ,
13 * list , 。Redis list , , , ,
14 * Redis ,
15 */
16
17 #region
18
19
20 client.EnqueueItemOnList("QueueList", "1. "); //
21 client.EnqueueItemOnList("QueueList", "2. ");
22 client.EnqueueItemOnList("QueueList", "3. ");
23 client.EnqueueItemOnList("QueueList", "4. ");
24 int q = client.GetListCount("QueueList");
25 for (int i = 0; i < q; i++)
26 {
27 //
28 // ( )
29 Console.WriteLine("QueueList :{0}", client.DequeueItemFromList("QueueList"));
30 }
31 #endregion
32 #region
33
34 client.PushItemToList("StackList", "1. "); //
35 client.PushItemToList("StackList", "2. ");
36 client.PushItemToList("StackList", "3. ");
37 client.PushItemToList("StackList", "4. ");
38 int p = client.GetListCount("StackList");
39 for (int i = 0; i < p; i++)
40 {
41 //
42 // ( )
43 Console.WriteLine("StackList :{0}", client.PopItemFromList("StackList"));
44 }
45 #endregion
46
47 }
転載先:https://www.cnblogs.com/happygx/p/8416613.html