Exemplo n.º 1
0
        private static void IndexCrawlDate(RedisClient Redis)
        {
            List<string> linkList = Redis.GetHashKeys("urn:link:data-last-date-crawl");
            int i = 0;
            Array.ForEach(linkList.ToArray(), link =>
            {
                i++;
                Console.WriteLine(i + " of " + linkList.Count);

                string dateValue = Redis.GetValueFromHash("urn:link:data-last-date-crawl", link);

                string serializedLinks = Redis.GetValueFromHash("urn:link:date-last-crawl",
                    Convert.ToDateTime(dateValue).Date.ToString());

                List<string> links;
                if (string.IsNullOrEmpty(serializedLinks))
                    links = new List<string>();
                else
                    links = serializedLinks.JsonDeserialize<List<string>>();

                if (!links.Contains(link))
                {
                    links.Add(link);
                    Redis.SetEntryInHash("urn:link:date-last-crawl",
                        Convert.ToDateTime(dateValue).Date.ToString(), links.JsonSerialize());
                }
            });
        }
Exemplo n.º 2
0
 private static void TestHash()
 {
     using (var client = new RedisClient("127.0.0.1", 6379))
     {
         client.SetEntryInHash("HQF.Tutorial.Redis:userInfoId", "name", "zhangsan");
         client.SetEntryInHash("HQF.Tutorial.Redis:userInfoId", "name1", "zhangsan1");
         client.SetEntryInHash("HQF.Tutorial.Redis:userInfoId", "name2", "zhangsan2");
         client.SetEntryInHash("HQF.Tutorial.Redis:userInfoId", "name3", "zhangsan3");
         client.GetHashKeys("HQF.Tutorial.Redis:userInfoId").ForEach(e => Console.WriteLine(e));
         client.GetHashValues("HQF.Tutorial.Redis:userInfoId").ForEach(e => Console.WriteLine(e));
     }
 }