Uploaded image for project: 'HttpComponents HttpClient'
  1. HttpComponents HttpClient
  2. HTTPCLIENT-1395

Call the storage implementation only once on a cache miss

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    Description

      I am trying to use the httpclient-cache component with a Cassandra backend. Everything seems good except that HttpCacheStorage#getEntry is getting called 3 times the first time resulting in a performance bottleneck. There might be a way to handle this in the Storage implementation by caching the recently queried values but I think that a better place is in the CachingHttpClient class. The current code expects zero latency to the storage backend(the current implementations are all memory based) but here is a patch that fixes the problem. Some notes:

      • I am using the code from the 4.2.5 release(but can port the code to the current trunk)
      • test is provided in org.apache.http.impl.client.cache.TestCachingHttpClient
      • BasicHttpCache is patched to expose methods that check if the key is found or if a proper variant is found - without this there is no way to say if there was a real cache miss or the specific variant is missing
      • CachingHttpClient is checking if the current HttpCache implementation is BasicHttpCache so it can use the new methods - I didn't want to change the interface because this will add breaking changes to the API
      • This exposes the alreadyHaveNewerCacheEntry method so implementations can control if the client should check for a more recent version in the cache

      Attachments

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            olegk Oleg Kalnichevski
            nikolavp Nikola Petrov
            Votes:
            2 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment