Class BasicHttpCache

  • All Implemented Interfaces:
    HttpCache

    class BasicHttpCache
    extends java.lang.Object
    implements HttpCache
    • Method Detail

      • flushCacheEntriesFor

        public void flushCacheEntriesFor​(org.apache.http.HttpHost host,
                                         org.apache.http.HttpRequest request)
                                  throws java.io.IOException
        Description copied from interface: HttpCache
        Clear all matching HttpCacheEntrys.
        Specified by:
        flushCacheEntriesFor in interface HttpCache
        Throws:
        java.io.IOException
      • flushInvalidatedCacheEntriesFor

        public void flushInvalidatedCacheEntriesFor​(org.apache.http.HttpHost host,
                                                    org.apache.http.HttpRequest request,
                                                    org.apache.http.HttpResponse response)
        Description copied from interface: HttpCache
        Clear any entries that may be invalidated by the given response to a particular request.
        Specified by:
        flushInvalidatedCacheEntriesFor in interface HttpCache
      • storeInCache

        void storeInCache​(org.apache.http.HttpHost target,
                          org.apache.http.HttpRequest request,
                          HttpCacheEntry entry)
                   throws java.io.IOException
        Throws:
        java.io.IOException
      • storeNonVariantEntry

        void storeNonVariantEntry​(org.apache.http.HttpHost target,
                                  org.apache.http.HttpRequest req,
                                  HttpCacheEntry entry)
                           throws java.io.IOException
        Throws:
        java.io.IOException
      • storeVariantEntry

        void storeVariantEntry​(org.apache.http.HttpHost target,
                               org.apache.http.HttpRequest req,
                               HttpCacheEntry entry)
                        throws java.io.IOException
        Throws:
        java.io.IOException
      • reuseVariantEntryFor

        public void reuseVariantEntryFor​(org.apache.http.HttpHost target,
                                         org.apache.http.HttpRequest req,
                                         Variant variant)
                                  throws java.io.IOException
        Description copied from interface: HttpCache
        Specifies cache should reuse the given cached variant to satisfy requests whose varying headers match those of the given client request.
        Specified by:
        reuseVariantEntryFor in interface HttpCache
        Parameters:
        target - host of the upstream client request
        req - request sent by upstream client
        variant - variant cache entry to reuse
        Throws:
        java.io.IOException - may be thrown during cache update
      • isIncompleteResponse

        boolean isIncompleteResponse​(org.apache.http.HttpResponse resp,
                                     Resource resource)
      • generateIncompleteResponseError

        CloseableHttpResponse generateIncompleteResponseError​(org.apache.http.HttpResponse response,
                                                              Resource resource)
      • doGetUpdatedParentEntry

        HttpCacheEntry doGetUpdatedParentEntry​(java.lang.String requestId,
                                               HttpCacheEntry existing,
                                               HttpCacheEntry entry,
                                               java.lang.String variantKey,
                                               java.lang.String variantCacheKey)
                                        throws java.io.IOException
        Throws:
        java.io.IOException
      • updateCacheEntry

        public HttpCacheEntry updateCacheEntry​(org.apache.http.HttpHost target,
                                               org.apache.http.HttpRequest request,
                                               HttpCacheEntry stale,
                                               org.apache.http.HttpResponse originResponse,
                                               java.util.Date requestSent,
                                               java.util.Date responseReceived)
                                        throws java.io.IOException
        Description copied from interface: HttpCache
        Update a HttpCacheEntry using a 304 HttpResponse.
        Specified by:
        updateCacheEntry in interface HttpCache
        Returns:
        the updated HttpCacheEntry
        Throws:
        java.io.IOException
      • updateVariantCacheEntry

        public HttpCacheEntry updateVariantCacheEntry​(org.apache.http.HttpHost target,
                                                      org.apache.http.HttpRequest request,
                                                      HttpCacheEntry stale,
                                                      org.apache.http.HttpResponse originResponse,
                                                      java.util.Date requestSent,
                                                      java.util.Date responseReceived,
                                                      java.lang.String cacheKey)
                                               throws java.io.IOException
        Description copied from interface: HttpCache
        Update a specific HttpCacheEntry representing a cached variant using a 304 HttpResponse.
        Specified by:
        updateVariantCacheEntry in interface HttpCache
        Parameters:
        target - host for client request
        request - actual request from upstream client
        stale - current variant cache entry
        originResponse - 304 response received from origin
        requestSent - when the validating request was sent
        responseReceived - when the validating response was received
        cacheKey - where in the cache this entry is currently stored
        Returns:
        the updated HttpCacheEntry
        Throws:
        java.io.IOException
      • cacheAndReturnResponse

        public org.apache.http.HttpResponse cacheAndReturnResponse​(org.apache.http.HttpHost host,
                                                                   org.apache.http.HttpRequest request,
                                                                   org.apache.http.HttpResponse originResponse,
                                                                   java.util.Date requestSent,
                                                                   java.util.Date responseReceived)
                                                            throws java.io.IOException
        Description copied from interface: HttpCache
        Store a HttpResponse in the cache if possible, and return
        Specified by:
        cacheAndReturnResponse in interface HttpCache
        Returns:
        the HttpResponse
        Throws:
        java.io.IOException
      • cacheAndReturnResponse

        public CloseableHttpResponse cacheAndReturnResponse​(org.apache.http.HttpHost host,
                                                            org.apache.http.HttpRequest request,
                                                            CloseableHttpResponse originResponse,
                                                            java.util.Date requestSent,
                                                            java.util.Date responseReceived)
                                                     throws java.io.IOException
        Description copied from interface: HttpCache
        Store a HttpResponse in the cache if possible, and return
        Specified by:
        cacheAndReturnResponse in interface HttpCache
        Returns:
        the HttpResponse
        Throws:
        java.io.IOException
      • getCacheEntry

        public HttpCacheEntry getCacheEntry​(org.apache.http.HttpHost host,
                                            org.apache.http.HttpRequest request)
                                     throws java.io.IOException
        Description copied from interface: HttpCache
        Retrieve matching HttpCacheEntry from the cache if it exists
        Specified by:
        getCacheEntry in interface HttpCache
        Returns:
        the matching HttpCacheEntry or null
        Throws:
        java.io.IOException
      • flushInvalidatedCacheEntriesFor

        public void flushInvalidatedCacheEntriesFor​(org.apache.http.HttpHost host,
                                                    org.apache.http.HttpRequest request)
                                             throws java.io.IOException
        Description copied from interface: HttpCache
        Clear invalidated matching HttpCacheEntrys
        Specified by:
        flushInvalidatedCacheEntriesFor in interface HttpCache
        Throws:
        java.io.IOException
      • getVariantCacheEntriesWithEtags

        public java.util.Map<java.lang.String,​Variant> getVariantCacheEntriesWithEtags​(org.apache.http.HttpHost host,
                                                                                             org.apache.http.HttpRequest request)
                                                                                      throws java.io.IOException
        Description copied from interface: HttpCache
        Retrieve all variants from the cache, if there are no variants then an empty Map is returned
        Specified by:
        getVariantCacheEntriesWithEtags in interface HttpCache
        Returns:
        a Map mapping Etags to variant cache entries
        Throws:
        java.io.IOException
      • addVariantWithEtag

        private void addVariantWithEtag​(java.lang.String variantKey,
                                        java.lang.String variantCacheKey,
                                        java.util.Map<java.lang.String,​Variant> variants)
                                 throws java.io.IOException
        Throws:
        java.io.IOException