Example #1
0
    async Task UpdatePostCache(Blog blog)
    {
        var dbPosts = await _repo.GetAllPostsAsync(blog.Id);

        var cachePosts = await _cache.GetPostsAsync(blog.Id, null);

        var updatedPosts = dbPosts.Except(cachePosts.Item ?? new List <Post>());

        if (updatedPosts.Count() > 0)
        {
            await _cache.AddPostsAsync(updatedPosts);

            _logger.LogInformation("{service} pdated {count} posts(s)", nameof(BlogCacheProcessingService), updatedPosts.Count());
        }
    }