/// <summary> /// 启动redis /// </summary> public void Start(LuceneTools luceneTools) { //开启一个异步线程 Task.Run(() => { while (true) { var commodityList = _rListService.Get(listKey); if (commodityList.Count > 0) { Console.WriteLine($"当前redis 对象的包含的list集合的数量是{commodityList.Count}"); var strList = _rListService.BlockingDequeueItemFromList(listKey, TimeSpan.FromHours(1)); //1.将值转换为List集合 GM_Commodity entity = Common.JsonHelper.ToObject <GM_Commodity>(strList); //2.检查索引中是否有该对象,如果有那么就更新索引 luceneTools.UpdateIndex(entity); ////3:更新成功再次查询数据 //luceneTools.QueryList("Title:asus", new Page() { Sort = "Price" }, "[100,200]"); } else { Thread.Sleep(1000); } } }); }