Package com.jms.socialmedia.cache
Class CachingServiceWithMetrics
- java.lang.Object
-
- com.jms.socialmedia.cache.AbstractCachingService
-
- com.jms.socialmedia.cache.CachingServiceWithMetrics
-
public class CachingServiceWithMetrics extends AbstractCachingService
-
-
Constructor Summary
Constructors Constructor Description CachingServiceWithMetrics(AbstractCachingService cachingService, com.codahale.metrics.MetricRegistry metricRegistry)
CachingServiceWithMetrics(AbstractCachingService cachingService, com.codahale.metrics.MetricRegistry metricRegistry, String metricsName)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
commentsCacheHit()
protected void
commentsCacheMiss()
void
editCommentInCache(int commentId, String text)
Either edits the text of the Comment in the Cache, or invalidates the Commentvoid
editPostInCache(int postId, String text)
Either edits the text of the Post in the Cache, or invalidates the PostComment
getCommentFromCache(int commentId)
Collection<Comment>
getCommentsFromCache(int postId)
Post
getPostFromCache(int postId)
Retrieves aPost
from cache if presentUser
getUserSessionFromCache(String sessionKey)
void
likeCommentInCache(int commentId, int userId)
Either adds a Like to the Comment in the Cache, or invalidates the Commentvoid
likePostInCache(int postId, int userId)
Either adds a Like to the Post in the Cache, or invalidates the Postprotected void
postCacheHit()
protected void
postCacheMiss()
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)
void
unlikeCommentInCache(int commentId, int userId)
Either removes a Like in the Comment in the Cache, or invalidates the Commentvoid
unlikePostInCache(int postId, int userId)
Either removes a Like in the Post in the Cache, or invalidates the Postprotected void
userSessionCacheHit()
protected void
userSessionCacheMiss()
-
Methods inherited from class com.jms.socialmedia.cache.AbstractCachingService
getCommentsFromCacheOrSupplier, getPostFromCacheOrSupplier, getUserSessionCacheOrSupplier
-
-
-
-
Constructor Detail
-
CachingServiceWithMetrics
public CachingServiceWithMetrics(AbstractCachingService cachingService, com.codahale.metrics.MetricRegistry metricRegistry)
-
CachingServiceWithMetrics
public CachingServiceWithMetrics(AbstractCachingService cachingService, com.codahale.metrics.MetricRegistry metricRegistry, String metricsName)
-
-
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
-
editPostInCache
public void editPostInCache(int postId, String text)
Description copied from class:AbstractCachingService
Either edits the text of the Post in the Cache, or invalidates the Post- Specified by:
editPostInCache
in classAbstractCachingService
- Parameters:
postId
- ID of the Post being editedtext
- New text of the Post
-
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
-
likePostInCache
public void likePostInCache(int postId, int userId)
Description copied from class:AbstractCachingService
Either adds a Like to the Post in the Cache, or invalidates the Post- Specified by:
likePostInCache
in classAbstractCachingService
- Parameters:
postId
- ID of the Post being likeduserId
- ID of the User the liked the Post
-
unlikePostInCache
public void unlikePostInCache(int postId, int userId)
Description copied from class:AbstractCachingService
Either removes a Like in the Post in the Cache, or invalidates the Post- Specified by:
unlikePostInCache
in classAbstractCachingService
- Parameters:
postId
- ID of the Post being unlikeduserId
- ID of the User the unliked the Post
-
getCommentsFromCache
public Collection<Comment> getCommentsFromCache(int postId)
- Specified by:
getCommentsFromCache
in classAbstractCachingService
-
getCommentFromCache
public Comment getCommentFromCache(int commentId)
- Specified by:
getCommentFromCache
in classAbstractCachingService
-
editCommentInCache
public void editCommentInCache(int commentId, String text)
Description copied from class:AbstractCachingService
Either edits the text of the Comment in the Cache, or invalidates the Comment- Specified by:
editCommentInCache
in classAbstractCachingService
- Parameters:
commentId
- ID of the Comment being editedtext
- New text of the Comment
-
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
-
likeCommentInCache
public void likeCommentInCache(int commentId, int userId)
Description copied from class:AbstractCachingService
Either adds a Like to the Comment in the Cache, or invalidates the Comment- Specified by:
likeCommentInCache
in classAbstractCachingService
- Parameters:
commentId
- ID of the Comment being likeduserId
- ID of the User the liked the Comment
-
unlikeCommentInCache
public void unlikeCommentInCache(int commentId, int userId)
Description copied from class:AbstractCachingService
Either removes a Like in the Comment in the Cache, or invalidates the Comment- Specified by:
unlikeCommentInCache
in classAbstractCachingService
- Parameters:
commentId
- ID of the Comment being unlikeduserId
- ID of the User the unliked the Comment
-
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
-
postCacheHit
protected void postCacheHit()
- Overrides:
postCacheHit
in classAbstractCachingService
-
postCacheMiss
protected void postCacheMiss()
- Overrides:
postCacheMiss
in classAbstractCachingService
-
commentsCacheHit
protected void commentsCacheHit()
- Overrides:
commentsCacheHit
in classAbstractCachingService
-
commentsCacheMiss
protected void commentsCacheMiss()
- Overrides:
commentsCacheMiss
in classAbstractCachingService
-
userSessionCacheHit
protected void userSessionCacheHit()
- Overrides:
userSessionCacheHit
in classAbstractCachingService
-
userSessionCacheMiss
protected void userSessionCacheMiss()
- Overrides:
userSessionCacheMiss
in classAbstractCachingService
-
-