From 82cbd49555a723f91ed3684a64debeade9c0b3f8 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Fri, 2 Aug 2019 15:58:45 +0300 Subject: More caches --- .../java/com/juick/server/configuration/WwwAppConfiguration.java | 2 +- src/main/java/com/juick/service/MessagesService.java | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) (limited to 'src/main') diff --git a/src/main/java/com/juick/server/configuration/WwwAppConfiguration.java b/src/main/java/com/juick/server/configuration/WwwAppConfiguration.java index 0c5c8dbf..45950eb0 100644 --- a/src/main/java/com/juick/server/configuration/WwwAppConfiguration.java +++ b/src/main/java/com/juick/server/configuration/WwwAppConfiguration.java @@ -63,7 +63,7 @@ public class WwwAppConfiguration implements WebMvcConfigurer { private String imgDir; @Bean public CacheManager cacheManager() { - return new CaffeineCacheManager("help", "users_by_name", "discussions"); + return new CaffeineCacheManager("help", "users_by_name", "discussions", "messages", "replies"); } @Bean diff --git a/src/main/java/com/juick/service/MessagesService.java b/src/main/java/com/juick/service/MessagesService.java index 490e0cfc..2b75a53a 100644 --- a/src/main/java/com/juick/service/MessagesService.java +++ b/src/main/java/com/juick/service/MessagesService.java @@ -32,10 +32,10 @@ import java.util.*; * Created by aalexeev on 11/13/16. */ public interface MessagesService { - @CacheEvict(value = "discussions", allEntries = true) + @CacheEvict(value = { "discussions", "messages", "replies" }, allEntries = true) int createMessage(int uid, String txt, String attachment, List tags); - @CacheEvict(value = "discussions", allEntries = true) + @CacheEvict(value = { "discussions", "messages", "replies" }, allEntries = true) int createReply(int mid, int rid, User user, String txt, String attachment); int getReplyIDIncrement(int mid); @@ -87,7 +87,7 @@ public interface MessagesService { List getPrivate(int uid, int before); - @Cacheable(value = "discussions", key="#uid") + @Cacheable(value = "discussions", key="#uid + #to") List getDiscussions(int uid, Long to); List getRecommended(int uid, int before); @@ -112,10 +112,12 @@ public interface MessagesService { List getUserSearch(User visitor, int UID, String search, int privacy, int page); + @Cacheable(value = "messages", key="#visitor.uid + #mids.hashCode()") List getMessages(User visitor, List mids); Map> updateReactionsFor(final List mid); + @Cacheable(value = "replies", key="#user.uid + #mid") List getReplies(User user, int mid); boolean setMessagePopular(int mid, int popular); -- cgit v1.2.3