diff options
author | Vitaly Takmazov | 2022-04-07 11:13:58 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2022-12-08 08:09:37 +0300 |
commit | 912171165155ff78ad111c9c4043844c34567a42 (patch) | |
tree | 876278eb4338d73d294ef55f10471d08f2b3e38b /src/main/java/com/juick/service/MessagesService.java | |
parent | a6dff3324a55540877deaed23083ea502706a5ae (diff) |
Configure caches
* caching is disabled because of OOMs in production
Diffstat (limited to 'src/main/java/com/juick/service/MessagesService.java')
-rw-r--r-- | src/main/java/com/juick/service/MessagesService.java | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/main/java/com/juick/service/MessagesService.java b/src/main/java/com/juick/service/MessagesService.java index d102031d..3fdd2b9e 100644 --- a/src/main/java/com/juick/service/MessagesService.java +++ b/src/main/java/com/juick/service/MessagesService.java @@ -23,6 +23,8 @@ import com.juick.model.User; import com.juick.model.ResponseReply; import com.juick.model.Tag; import org.apache.commons.lang3.tuple.Pair; +import org.springframework.cache.annotation.CacheEvict; +import org.springframework.cache.annotation.Cacheable; import java.net.URI; import java.util.*; @@ -31,8 +33,10 @@ import java.util.*; * Created by aalexeev on 11/13/16. */ public interface MessagesService { + @CacheEvict(value = { "discussions", "messages", "replies" }, allEntries = true) int createMessage(int uid, String txt, String attachment, Set<Tag> tags); + @CacheEvict(value = { "discussions", "messages", "replies" }, allEntries = true) int createReply(int mid, int rid, User user, String txt, String attachment); enum RecommendStatus { Error, @@ -83,6 +87,7 @@ public interface MessagesService { List<Integer> getPrivate(int uid, int before); + @Cacheable(value = "discussions", key="#uid + #to") List<Integer> getDiscussions(int uid, Long to); /** @@ -111,10 +116,12 @@ public interface MessagesService { List<Integer> getUserSearch(User visitor, int UID, String search, int privacy, int page); + @Cacheable(value = "messages", key="#visitor.uid + #mids.hashCode()") List<Message> getMessages(User visitor, List<Integer> mids); Map<Integer,Set<Reaction>> updateReactionsFor(final List<Integer> mid); + @Cacheable(value = "replies", key="#user.uid + #mid") List<Message> getReplies(User user, int mid); boolean setMessagePrivacy(int mid); |