public int GetCommentCountByPostId(int id) { var comments = CacheRepository.GetItems <Comment>($"{CommentsByPostIdCache}-{id}"); if (comments != null) { return(comments.Count()); } return(CommentRepository.GetCountByPostId(id)); }
public IEnumerable <Comment> GetCommentsWithTools(OptionsCollectionById options) { var comments = CacheRepository.GetItems <Comment>(GetOptionsString(options)); if (comments != null) { return(comments); } comments = CommentRepository.GetWithOptions(options); CacheRepository.Add(comments, GetOptionsString(options)); return(comments); }
public IEnumerable <Comment> GetCommentsByPostId(int id) { var comments = CacheRepository.GetItems <Comment>($"{CommentsByPostIdCache}-{id}"); if (comments != null) { return(comments); } comments = CommentRepository.GetByPostId(id).Reverse(); CacheRepository.Add(comments, $"{CommentsByPostIdCache}-{id}"); return(comments); }