Merge pull request #988 from nagisa77/codex/update-post_cache_name-to-handle-pagination

Fix post cache keys to include pagination parameters
This commit is contained in:
Tim
2025-09-17 11:53:05 +08:00
committed by GitHub
2 changed files with 13 additions and 13 deletions

View File

@@ -52,7 +52,7 @@ public class CommentService {
@CacheEvict( @CacheEvict(
value = CachingConfig.POST_CACHE_NAME, value = CachingConfig.POST_CACHE_NAME,
key = "'latest_reply'" allEntries = true
) )
@Transactional @Transactional
public Comment addComment(String username, Long postId, String content) { public Comment addComment(String username, Long postId, String content) {
@@ -104,7 +104,7 @@ public class CommentService {
@CacheEvict( @CacheEvict(
value = CachingConfig.POST_CACHE_NAME, value = CachingConfig.POST_CACHE_NAME,
key = "'latest_reply'" allEntries = true
) )
@Transactional @Transactional
public Comment addReply(String username, Long parentId, String content) { public Comment addReply(String username, Long parentId, String content) {
@@ -241,7 +241,7 @@ public class CommentService {
@CacheEvict( @CacheEvict(
value = CachingConfig.POST_CACHE_NAME, value = CachingConfig.POST_CACHE_NAME,
key = "'latest_reply'" allEntries = true
) )
@Transactional @Transactional
public void deleteComment(String username, Long id) { public void deleteComment(String username, Long id) {
@@ -260,7 +260,7 @@ public class CommentService {
@CacheEvict( @CacheEvict(
value = CachingConfig.POST_CACHE_NAME, value = CachingConfig.POST_CACHE_NAME,
key = "'latest_reply'" allEntries = true
) )
@Transactional @Transactional
public void deleteCommentCascade(Comment comment) { public void deleteCommentCascade(Comment comment) {

View File

@@ -509,7 +509,7 @@ public class PostService {
@Cacheable( @Cacheable(
value = CachingConfig.POST_CACHE_NAME, value = CachingConfig.POST_CACHE_NAME,
key = "'latest_reply'" key = "new org.springframework.cache.interceptor.SimpleKey('latest_reply', #categoryIds, #tagIds, #page, #pageSize)"
) )
public List<Post> listPostsByLatestReply(java.util.List<Long> categoryIds, public List<Post> listPostsByLatestReply(java.util.List<Long> categoryIds,
java.util.List<Long> tagIds, java.util.List<Long> tagIds,
@@ -648,7 +648,7 @@ public class PostService {
*/ */
@Cacheable( @Cacheable(
value = CachingConfig.POST_CACHE_NAME, value = CachingConfig.POST_CACHE_NAME,
key = "'default'" key = "new org.springframework.cache.interceptor.SimpleKey('default', #ids, #tids, #page, #pageSize)"
) )
public List<Post> defaultListPosts(List<Long> ids, List<Long> tids, Integer page, Integer pageSize){ public List<Post> defaultListPosts(List<Long> ids, List<Long> tids, Integer page, Integer pageSize){
boolean hasCategories = !CollectionUtils.isEmpty(ids); boolean hasCategories = !CollectionUtils.isEmpty(ids);
@@ -673,7 +673,7 @@ public class PostService {
@CacheEvict( @CacheEvict(
value = CachingConfig.POST_CACHE_NAME, value = CachingConfig.POST_CACHE_NAME,
key = "'default'" allEntries = true
) )
public Post approvePost(Long id) { public Post approvePost(Long id) {
Post post = postRepository.findById(id) Post post = postRepository.findById(id)
@@ -713,7 +713,7 @@ public class PostService {
@CacheEvict( @CacheEvict(
value = CachingConfig.POST_CACHE_NAME, value = CachingConfig.POST_CACHE_NAME,
key = "'default'" allEntries = true
) )
public Post pinPost(Long id, String username) { public Post pinPost(Long id, String username) {
Post post = postRepository.findById(id) Post post = postRepository.findById(id)
@@ -729,7 +729,7 @@ public class PostService {
@CacheEvict( @CacheEvict(
value = CachingConfig.POST_CACHE_NAME, value = CachingConfig.POST_CACHE_NAME,
key = "'default'" allEntries = true
) )
public Post unpinPost(Long id, String username) { public Post unpinPost(Long id, String username) {
Post post = postRepository.findById(id) Post post = postRepository.findById(id)
@@ -745,7 +745,7 @@ public class PostService {
@CacheEvict( @CacheEvict(
value = CachingConfig.POST_CACHE_NAME, value = CachingConfig.POST_CACHE_NAME,
key = "'default'" allEntries = true
) )
public Post closePost(Long id, String username) { public Post closePost(Long id, String username) {
Post post = postRepository.findById(id) Post post = postRepository.findById(id)
@@ -764,7 +764,7 @@ public class PostService {
@CacheEvict( @CacheEvict(
value = CachingConfig.POST_CACHE_NAME, value = CachingConfig.POST_CACHE_NAME,
key = "'default'" allEntries = true
) )
public Post reopenPost(Long id, String username) { public Post reopenPost(Long id, String username) {
Post post = postRepository.findById(id) Post post = postRepository.findById(id)
@@ -783,7 +783,7 @@ public class PostService {
@CacheEvict( @CacheEvict(
value = CachingConfig.POST_CACHE_NAME, value = CachingConfig.POST_CACHE_NAME,
key = "'default'" allEntries = true
) )
@Transactional @Transactional
public Post updatePost(Long id, public Post updatePost(Long id,
@@ -840,7 +840,7 @@ public class PostService {
@CacheEvict( @CacheEvict(
value = CachingConfig.POST_CACHE_NAME, value = CachingConfig.POST_CACHE_NAME,
key = "'default'" allEntries = true
) )
@Transactional @Transactional
public void deletePost(Long id, String username) { public void deletePost(Long id, String username) {