Interface CacheFile


  • @ProviderType
    public interface CacheFile
    A cache file contains the response headers and body that can be delivered on subsequent requests for the same resource. TODO: currently there are methods that only makes sense while either using an existing cache file or creating a new one: it might be more appropriate to create separate interfaces for that.
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      void discard()
      Discard this cache file.
      Headers getHeaders()
      Return the HTTP response headers stored with this entry.
      java.lang.String getKey()
      Return the cache key.
      javax.servlet.ServletOutputStream getOutputStream​(javax.servlet.ServletOutputStream base)
      Open an output stream that will contain a copy of the response body.
      java.io.PrintWriter getWriter​(java.io.PrintWriter base, java.lang.String encoding)
      Open a print writer.
      boolean save()
      Keep this cache file.
      void spool​(javax.servlet.http.HttpServletResponse response)
      Spool the cache file's contents to a response.
    • Method Detail

      • getKey

        java.lang.String getKey()
        Return the cache key.
        Returns:
        cache key
      • getHeaders

        Headers getHeaders()
        Return the HTTP response headers stored with this entry.
        Returns:
        response headers
      • spool

        void spool​(javax.servlet.http.HttpServletResponse response)
            throws java.io.IOException
        Spool the cache file's contents to a response.
        Parameters:
        response - servlet response
        Throws:
        java.io.IOException - if an I/O error occurs
      • getOutputStream

        javax.servlet.ServletOutputStream getOutputStream​(javax.servlet.ServletOutputStream base)
                                                   throws java.io.IOException
        Open an output stream that will contain a copy of the response body.
        Parameters:
        base - base output stream
        Returns:
        servlet output stream
        Throws:
        java.io.IOException - if an I/O error occurs
      • getWriter

        java.io.PrintWriter getWriter​(java.io.PrintWriter base,
                                      java.lang.String encoding)
                               throws java.io.IOException
        Open a print writer.
        Parameters:
        base - base writer
        encoding - response body encoding
        Returns:
        writer
        Throws:
        java.io.IOException - if an I/O error occurs
      • save

        boolean save()
        Keep this cache file.
        Returns:
        true if the save was successful; false otherwise
      • discard

        void discard()
        Discard this cache file.