當前位置: 首頁>>代碼示例>>C#>>正文


C# RedisClient.GetAllItemsFromList方法代碼示例

本文整理匯總了C#中ServiceStack.Redis.RedisClient.GetAllItemsFromList方法的典型用法代碼示例。如果您正苦於以下問題:C# RedisClient.GetAllItemsFromList方法的具體用法?C# RedisClient.GetAllItemsFromList怎麽用?C# RedisClient.GetAllItemsFromList使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在ServiceStack.Redis.RedisClient的用法示例。


在下文中一共展示了RedisClient.GetAllItemsFromList方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: TestList

        private static void TestList()
        {
            using (var client = new RedisClient("127.0.0.1", 6379))
            {
                #region "List類型"

                client.AddItemToList("HQF.Tutorial.Redis:userInfoId1", "123");
                client.AddItemToList("HQF.Tutorial.Redis:userInfoId1", "1234");

                Console.WriteLine("List數據項條數:" + client.GetListCount("HQF.Tutorial.Redis:userInfoId1"));
                Console.WriteLine("List數據項第一條數據:" + client.GetItemFromList("HQF.Tutorial.Redis:userInfoId1", 0));
                Console.WriteLine("List所有數據");
                client.GetAllItemsFromList("HQF.Tutorial.Redis:userInfoId1").ForEach(e => Console.WriteLine(e));
                #endregion

                #region "List類型做為隊列和棧使用"
                Console.WriteLine(client.GetListCount("HQF.Tutorial.Redis:userInfoId1"));
                //隊列先進先出
                //Console.WriteLine(client.DequeueItemFromList("userInfoId1"));
                //Console.WriteLine(client.DequeueItemFromList("userInfoId1"));

                //棧後進先出
                Console.WriteLine("出棧" + client.PopItemFromList("HQF.Tutorial.Redis:userInfoId1"));
                Console.WriteLine("出棧" + client.PopItemFromList("HQF.Tutorial.Redis:userInfoId1"));
                #endregion
            }
        }
開發者ID:huoxudong125,項目名稱:HQF.Tutorial.Redis,代碼行數:27,代碼來源:Program.cs

示例2: IndexDomainOrSubdomain

        private static void IndexDomainOrSubdomain(RedisClient Redis)
        {
            List<string> keys = Redis.SearchKeys("urn:link:domain-or-subdomain:*");
            for (int i = 0; i < keys.Count; i++)
            {
                List<string> links = Redis.GetAllItemsFromList(keys[i]);

                string domainOrSubdomain = keys[0].Substring(29);

                Console.WriteLine(i + ": " + domainOrSubdomain);

                Redis.SetEntryInHash("urn:link:domain-or-subdomain",
                    domainOrSubdomain, links.JsonSerialize());
            }
        }
開發者ID:quartz12345,項目名稱:c,代碼行數:15,代碼來源:Program.cs

示例3: simpleRedisGetSet

        static void simpleRedisGetSet()
        {
            string host = "localhost";
            string elementKey = "testKeyRedis";
            RedisClient redisclient = new RedisClient(host);
            redisclient.Remove(elementKey);
            var storeMembers = new List<string> { "asd","dsd","bb"};
            // storeMembers.ForEach(x=>redisclient.AddItemToList(elementKey,x));

            redisclient.AddRangeToList(elementKey,storeMembers);
            var members = redisclient.GetAllItemsFromList(elementKey);
            var list = redisclient.Lists[elementKey];
            list.Clear();
            var ser = new ObjectSerializer();
            bool result = redisclient.Set<byte[]>(elementKey, ser.Serialize(storeMembers));
            if (result)
            {
                var resultlist = ser.Deserialize(redisclient.Get<byte[]>(elementKey));
            }
            members.ForEach(s=>Console.WriteLine("list:"+s));
             //   Console.WriteLine("index2:"+redisclient.GetItemFromList(elementKey,1));
            //if (redisclient.Get<string>(elementKey) == null)
            //{
            //    redisclient.Set(elementKey, "defaultValue");
            //}
            //else {
            //    redisclient.Set(elementKey, "new default value");
            //}
            //Console.WriteLine("redise:value:"+redisclient.Get<string>(elementKey));
            Console.WriteLine(redisclient.Info);
        }
開發者ID:nzlzg,項目名稱:TestOne,代碼行數:31,代碼來源:Program.cs


注:本文中的ServiceStack.Redis.RedisClient.GetAllItemsFromList方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。