Package com.jms.socialmedia.cache
Class GuavaCachingService
- java.lang.Object
-
- com.jms.socialmedia.cache.AbstractCachingService
-
- com.jms.socialmedia.cache.AbstractHeapCachingService
-
- com.jms.socialmedia.cache.GuavaCachingService
-
public class GuavaCachingService extends AbstractHeapCachingService
-
-
Constructor Summary
Constructors Constructor Description GuavaCachingService()
GuavaCachingService(int maxNumberOfPosts, int maxNumberOfUserSessions)
GuavaCachingService(int maxNumberOfPosts, int maxNumberOfUserSessions, int expireTimeInSeconds)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Comment
getCommentFromCache(int commentId)
Collection<Comment>
getCommentsFromCache(int postId)
Post
getPostFromCache(int postId)
Retrieves aPost
from cache if presentUser
getUserSessionFromCache(String sessionKey)
void
putCommentIntoCache(Comment comment)
void
putCommentsFromPostIntoCache(int postId, Collection<Comment> comments)
void
putPostIntoCache(Post post)
void
putUserSessionIntoCache(String sessionKey, User user)
void
removeCommentFromCache(int commentId)
void
removePostFromCache(int postId)
void
removeUserSessionFromCache(String sessionKey)
-
Methods inherited from class com.jms.socialmedia.cache.AbstractHeapCachingService
editCommentInCache, editPostInCache, likeCommentInCache, likePostInCache, unlikeCommentInCache, unlikePostInCache
-
Methods inherited from class com.jms.socialmedia.cache.AbstractCachingService
commentsCacheHit, commentsCacheMiss, getCommentsFromCacheOrSupplier, getPostFromCacheOrSupplier, getUserSessionCacheOrSupplier, postCacheHit, postCacheMiss, userSessionCacheHit, userSessionCacheMiss
-
-
-
-
Method Detail
-
getPostFromCache
public Post getPostFromCache(int postId)
Description copied from class:AbstractCachingService
Retrieves aPost
from cache if present- Specified by:
getPostFromCache
in classAbstractCachingService
- Parameters:
postId
- ID of Post- Returns:
- Post or
null
-
putPostIntoCache
public void putPostIntoCache(Post post)
- Specified by:
putPostIntoCache
in classAbstractCachingService
-
removePostFromCache
public void removePostFromCache(int postId)
Description copied from class:AbstractCachingService
- Specified by:
removePostFromCache
in classAbstractCachingService
-
getCommentsFromCache
public Collection<Comment> getCommentsFromCache(int postId)
- Specified by:
getCommentsFromCache
in classAbstractCachingService
-
getCommentFromCache
public Comment getCommentFromCache(int commentId)
- Specified by:
getCommentFromCache
in classAbstractCachingService
-
putCommentIntoCache
public void putCommentIntoCache(Comment comment)
- Specified by:
putCommentIntoCache
in classAbstractCachingService
-
putCommentsFromPostIntoCache
public void putCommentsFromPostIntoCache(int postId, Collection<Comment> comments)
- Specified by:
putCommentsFromPostIntoCache
in classAbstractCachingService
-
removeCommentFromCache
public void removeCommentFromCache(int commentId)
- Specified by:
removeCommentFromCache
in classAbstractCachingService
-
getUserSessionFromCache
public User getUserSessionFromCache(String sessionKey)
- Specified by:
getUserSessionFromCache
in classAbstractCachingService
-
putUserSessionIntoCache
public void putUserSessionIntoCache(String sessionKey, User user)
- Specified by:
putUserSessionIntoCache
in classAbstractCachingService
-
removeUserSessionFromCache
public void removeUserSessionFromCache(String sessionKey)
- Specified by:
removeUserSessionFromCache
in classAbstractCachingService
-
-