public bool ContainPostCache(int postID) { PostV5 threadContent = ThreadContent; if (threadContent != null && threadContent.PostID == postID) { return(true); } PostCollectionV5[] cachedPosts = cachedPagePosts; if (cachedPosts == null) { return(false); } for (int i = 0; i < CacheFirstPageCount + CacheLastPageCount; i++) { PostCollectionV5 tempPosts = cachedPosts[i]; if (tempPosts != null && tempPosts.ContainsKey(postID)) { return(true); } } return(false); }
/// <summary> /// 更新缓存 如果缓存里不存在该帖子 则不进行任何操作 /// </summary> /// <param name="post"></param> public virtual void UpdatePostCache(PostV5 post) { lock (m_CachedPagePostsLocker) { PostV5 threadContent = ThreadContent; if (threadContent != null && post.PostID == threadContent.PostID) { ThreadContent = post; } else { if (cachedPagePosts != null) { for (int i = 0; i < CacheFirstPageCount + CacheLastPageCount; i++) { PostCollectionV5 posts = cachedPagePosts[i]; if (posts != null && posts.ContainsKey(post.PostID)) { posts.Set(post); break; } } } } } }