Package com.jms.socialmedia.cache
Class AbstractCachingService
- java.lang.Object
-
- com.jms.socialmedia.cache.AbstractCachingService
-
- Direct Known Subclasses:
AbstractCodecCachingService
,AbstractHeapCachingService
,CachingServiceWithMetrics
public abstract class AbstractCachingService extends Object
-
-
Constructor Summary
Constructors Constructor Description AbstractCachingService()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected void
commentsCacheHit()
protected void
commentsCacheMiss()
abstract void
editCommentInCache(int commentId, String text)
Either edits the text of the Comment in the Cache, or invalidates the Commentabstract void
editPostInCache(int postId, String text)
Either edits the text of the Post in the Cache, or invalidates the Postabstract Comment
getCommentFromCache(int commentId)
abstract Collection<Comment>
getCommentsFromCache(int postId)
Collection<Comment>
getCommentsFromCacheOrSupplier(int postId, Supplier<Collection<Comment>> supplier)
abstract Post
getPostFromCache(int postId)
Retrieves aPost
from cache if presentPost
getPostFromCacheOrSupplier(int postId, Supplier<Post> supplier)
User
getUserSessionCacheOrSupplier(String sessionKey, Supplier<User> supplier)
abstract User
getUserSessionFromCache(String sessionKey)
abstract void
likeCommentInCache(int commentId, int userId)
Either adds a Like to the Comment in the Cache, or invalidates the Commentabstract void
likePostInCache(int postId, int userId)
Either adds a Like to the Post in the Cache, or invalidates the Postprotected void
postCacheHit()
protected void
postCacheMiss()
abstract void
putCommentIntoCache(Comment comment)
abstract void
putCommentsFromPostIntoCache(int postId, Collection<Comment> comments)
abstract void
putPostIntoCache(Post post)
abstract void
putUserSessionIntoCache(String sessionKey, User user)
abstract void
removeCommentFromCache(int commentId)
abstract void
removePostFromCache(int postId)
abstract void
removeUserSessionFromCache(String sessionKey)
abstract void
unlikeCommentInCache(int commentId, int userId)
Either removes a Like in the Comment in the Cache, or invalidates the Commentabstract void
unlikePostInCache(int postId, int userId)
Either removes a Like in the Post in the Cache, or invalidates the Postprotected void
userSessionCacheHit()
protected void
userSessionCacheMiss()
-
-
-
Method Detail
-
getPostFromCache
public abstract Post getPostFromCache(int postId)
Retrieves aPost
from cache if present- Parameters:
postId
- ID of Post- Returns:
- Post or
null
-
editPostInCache
public abstract void editPostInCache(int postId, String text)
Either edits the text of the Post in the Cache, or invalidates the Post- Parameters:
postId
- ID of the Post being editedtext
- New text of the Post
-
putPostIntoCache
public abstract void putPostIntoCache(Post post)
-
removePostFromCache
public abstract void removePostFromCache(int postId)
- Parameters:
postId
-
-
likePostInCache
public abstract void likePostInCache(int postId, int userId)
Either adds a Like to the Post in the Cache, or invalidates the Post- Parameters:
postId
- ID of the Post being likeduserId
- ID of the User the liked the Post
-
unlikePostInCache
public abstract void unlikePostInCache(int postId, int userId)
Either removes a Like in the Post in the Cache, or invalidates the Post- Parameters:
postId
- ID of the Post being unlikeduserId
- ID of the User the unliked the Post
-
getCommentsFromCache
public abstract Collection<Comment> getCommentsFromCache(int postId)
-
getCommentFromCache
public abstract Comment getCommentFromCache(int commentId)
-
editCommentInCache
public abstract void editCommentInCache(int commentId, String text)
Either edits the text of the Comment in the Cache, or invalidates the Comment- Parameters:
commentId
- ID of the Comment being editedtext
- New text of the Comment
-
putCommentIntoCache
public abstract void putCommentIntoCache(Comment comment)
-
putCommentsFromPostIntoCache
public abstract void putCommentsFromPostIntoCache(int postId, Collection<Comment> comments)
-
removeCommentFromCache
public abstract void removeCommentFromCache(int commentId)
-
likeCommentInCache
public abstract void likeCommentInCache(int commentId, int userId)
Either adds a Like to the Comment in the Cache, or invalidates the Comment- Parameters:
commentId
- ID of the Comment being likeduserId
- ID of the User the liked the Comment
-
unlikeCommentInCache
public abstract void unlikeCommentInCache(int commentId, int userId)
Either removes a Like in the Comment in the Cache, or invalidates the Comment- Parameters:
commentId
- ID of the Comment being unlikeduserId
- ID of the User the unliked the Comment
-
removeUserSessionFromCache
public abstract void removeUserSessionFromCache(String sessionKey)
-
getPostFromCacheOrSupplier
public Post getPostFromCacheOrSupplier(int postId, Supplier<Post> supplier)
-
getCommentsFromCacheOrSupplier
public Collection<Comment> getCommentsFromCacheOrSupplier(int postId, Supplier<Collection<Comment>> supplier)
-
getUserSessionCacheOrSupplier
public User getUserSessionCacheOrSupplier(String sessionKey, Supplier<User> supplier)
-
postCacheHit
protected void postCacheHit()
-
postCacheMiss
protected void postCacheMiss()
-
commentsCacheHit
protected void commentsCacheHit()
-
commentsCacheMiss
protected void commentsCacheMiss()
-
userSessionCacheHit
protected void userSessionCacheHit()
-
userSessionCacheMiss
protected void userSessionCacheMiss()
-
-