From cef2623a14f2de68775bc70158b8616eeaaeea6e Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Fri, 9 Dec 2022 12:50:17 +0300 Subject: `discover` cache --- .../java/com/juick/service/MessagesService.java | 21 ++++++++++++++------- src/main/resources/application.properties | 2 +- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/juick/service/MessagesService.java b/src/main/java/com/juick/service/MessagesService.java index 626cc495..1afeb216 100644 --- a/src/main/java/com/juick/service/MessagesService.java +++ b/src/main/java/com/juick/service/MessagesService.java @@ -33,10 +33,10 @@ import java.util.*; * Created by aalexeev on 11/13/16. */ public interface MessagesService { - @CacheEvict(value = { "discussions", "messages", "replies" }, allEntries = true) + @CacheEvict(value = { "discover", "discussions", "messages", "replies" }, allEntries = true) int createMessage(int uid, String txt, String attachment, Set tags); - @CacheEvict(value = { "discussions", "messages", "replies" }, allEntries = true) + @CacheEvict(value = { "discover", "discussions", "messages", "replies" }, allEntries = true) int createReply(int mid, int rid, User user, String txt, String attachment); enum RecommendStatus { Error, @@ -44,14 +44,18 @@ public interface MessagesService { Deleted } + @CacheEvict(value = { "discover", "discussions", "messages", "replies" }, allEntries = true) RecommendStatus recommendMessage(int mid, int vuid, String userUri); + @CacheEvict(value = { "discover", "discussions", "messages", "replies" }, allEntries = true) RecommendStatus recommendMessage(int mid, int vuid); List listReactions(); + @CacheEvict(value = { "discover", "discussions", "messages", "replies" }, allEntries = true) RecommendStatus likeMessage(int mid, int vuid, Integer reaction); + @CacheEvict(value = { "discover", "discussions", "messages", "replies" }, allEntries = true) RecommendStatus likeMessage(int mid, int vuid, Integer reaction, String userUri); @@ -59,6 +63,7 @@ public interface MessagesService { boolean isReadOnly(int mid); + @CacheEvict(value = { "discover", "discussions", "messages", "replies" }, allEntries = true) void setReadOnly(int mid, boolean readonly); boolean isSubscribed(int uid, int mid); @@ -75,6 +80,7 @@ public interface MessagesService { List> getMessagesRecommendations(Collection mids); + @Cacheable(value = "discover", key="#visitorUid + #before") List getAll(int visitorUid, int before); List getTag(int tid, int visitorUid, int before, int cnt); @@ -119,6 +125,7 @@ public interface MessagesService { @Cacheable(value = "messages", key="#visitor.uid + #mids.hashCode()") List getMessages(User visitor, List mids); + @CacheEvict(value = { "discover", "discussions", "messages", "replies" }, allEntries = true) Map> updateReactionsFor(final List mid); @Cacheable(value = "replies", key="#user.uid + #mid") @@ -126,10 +133,10 @@ public interface MessagesService { boolean setMessagePrivacy(int mid); - @CacheEvict(value = { "discussions", "messages", "replies" }, allEntries = true) + @CacheEvict(value = { "discover", "discussions", "messages", "replies" }, allEntries = true) boolean deleteMessage(int uid, int mid); - @CacheEvict(value = { "discussions", "messages", "replies" }, allEntries = true) + @CacheEvict(value = { "discover", "discussions", "messages", "replies" }, allEntries = true) boolean deleteReply(int uid, int mid, int rid); List getLastMessages(int hours); @@ -144,15 +151,15 @@ public interface MessagesService { List getUnread(User user); - @CacheEvict(value = { "discussions", "messages", "replies" }, allEntries = true) + @CacheEvict(value = { "discover", "discussions", "messages", "replies" }, allEntries = true) boolean updateMessage(Integer mid, Integer rid, String body); - @CacheEvict(value = { "discussions", "messages", "replies" }, allEntries = true) + @CacheEvict(value = { "discover", "discussions", "messages", "replies" }, allEntries = true) boolean updateReplyUri(Message reply, URI replyUri); boolean replyExists(URI replyUri); - @CacheEvict(value = { "discussions", "messages", "replies" }, allEntries = true) + @CacheEvict(value = { "discover", "discussions", "messages", "replies" }, allEntries = true) boolean deleteReply(URI userUri, URI replyUri); String getMessageProperty(Integer mid, Integer rid, String key); diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index efda260f..b23842ee 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -7,5 +7,5 @@ spring.h2.console.enabled=true spring.datasource.generate-unique-name=false spring.sql.init.platform=h2 spring.cache.type=none -spring.cache.cache-names=help, users_by_name, discussions, messages, replies, popular_tags +spring.cache.cache-names=help, users_by_name, discover, discussions, messages, replies, popular_tags spring.profiles.active=@activatedProperties@ -- cgit v1.2.3