Class AbstractCachingService

    • Constructor Detail

      • AbstractCachingService

        public AbstractCachingService()
    • Method Detail

      • getPostFromCache

        public abstract Post getPostFromCache​(int postId)
        Retrieves a Post 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 edited
        text - New text of the Post
      • putPostIntoCache

        public abstract void putPostIntoCache​(Post post)
      • removePostFromCache

        public abstract void removePostFromCache​(int postId)
        Removes a Post and all of its Comments from cache
        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 liked
        userId - 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 unliked
        userId - 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 edited
        text - 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 liked
        userId - 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 unliked
        userId - ID of the User the unliked the Comment
      • getUserSessionFromCache

        public abstract User getUserSessionFromCache​(String sessionKey)
      • putUserSessionIntoCache

        public abstract void putUserSessionIntoCache​(String sessionKey,
                                                     User user)
      • removeUserSessionFromCache

        public abstract void removeUserSessionFromCache​(String sessionKey)
      • getPostFromCacheOrSupplier

        public Post getPostFromCacheOrSupplier​(int postId,
                                               Supplier<Post> 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()