/// <summary> /// Get the Forum Info - using examine, because that can be faster when /// there are lots and lots of posts - although i've yet to see it /// really get faster than the traverse method (yet) /// </summary> /// <param name="item"></param> /// <param name="useExamine">true to use examine</param> public static ForumCacheItem GetForumInfo(this IPublishedContent item, bool useExamine) { if (!useExamine) { return(GetForumInfo(item)); } ExamineManager.Instance.TryGetSearcher("InternalSearcher", out _); var cacheName = $"forum_{item.Id}"; var cache = Current.AppCaches.RuntimeCache; var forumInfo = cache.GetCacheItem <ForumCacheItem>(cacheName); if (forumInfo != null) { return(forumInfo); } //Stopwatch sw = new Stopwatch(); //sw.Start(); forumInfo = new ForumCacheItem(); ISearchResults searchResults = queryLastPostIndex(item, item.Name); ISearchResults updateResults = queryLastEditIndex(item, item.Name); forumInfo.Count = searchResults.ToList().Count - 1; forumInfo.latestPost = DateTime.MinValue; if (searchResults.Any()) { var lastpostdate = new DateTime(Convert.ToInt64(searchResults.First().Values["createDate"])); if (lastpostdate > DateTime.MinValue) { forumInfo.latestPost = lastpostdate; } forumInfo.lastpostAuthor = searchResults.First().Values["postCreator"]; } if (updateResults.Any()) { var latestedit = new DateTime(Convert.ToInt64(searchResults.First().Values["editDate"])); if (latestedit > DateTime.MinValue) { forumInfo.latestEdit = latestedit; } } cache.InsertCacheItem <ForumCacheItem>(cacheName, () => forumInfo); return(forumInfo); }