Package org.eclipse.jetty.http.content
Class CachingHttpContentFactory
java.lang.Object
org.eclipse.jetty.http.content.CachingHttpContentFactory
- All Implemented Interfaces:
HttpContent.Factory
- Direct Known Subclasses:
ValidatingCachingHttpContentFactory
HttpContent.Factory
implementation that wraps any other HttpContent.Factory
instance
using it as a caching authority. Only HttpContent instances whose path is not a directory are cached.
No eviction is done by this HttpContent.Factory
, once an entry is in the cache it is always
assumed to be valid. This class can be extended to implement the validation behaviours on
CachingHttpContentFactory.CachingHttpContent
which allow entries to be evicted once they become invalid.
The default values for the cache are:
- maxCachedFileSize: 268435456L
- maxCachedFiles: 2048
- maxCacheSize: 268435456L
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionprotected class
protected static interface
protected static class
-
Constructor Summary
ConstructorDescriptionCachingHttpContentFactory
(HttpContent.Factory authority, ByteBufferPool bufferPool) -
Method Summary
Modifier and TypeMethodDescriptionvoid
getCache()
int
long
getContent
(String path) int
Get the max number of cached files..int
long
protected boolean
isCacheable
(HttpContent httpContent) Tests whether the given HttpContent is cacheable, and if there is enough room to fit it in the cache.boolean
newCachedContent
(String p, HttpContent httpContent) protected void
void
setMaxCachedFiles
(int maxCachedFiles) Set the max number of cached files..void
setMaxCachedFileSize
(int maxCachedFileSize) void
setMaxCacheSize
(long maxCacheSize) void
setUseDirectByteBuffers
(boolean useDirectByteBuffers)
-
Constructor Details
-
CachingHttpContentFactory
-
-
Method Details
-
getCache
-
getCachedSize
public long getCachedSize() -
getCachedFiles
public int getCachedFiles() -
getMaxCachedFileSize
public int getMaxCachedFileSize() -
setMaxCachedFileSize
public void setMaxCachedFileSize(int maxCachedFileSize) -
getMaxCacheSize
public long getMaxCacheSize() -
setMaxCacheSize
public void setMaxCacheSize(long maxCacheSize) -
getMaxCachedFiles
public int getMaxCachedFiles()Get the max number of cached files..- Returns:
- the max number of cached files.
-
setMaxCachedFiles
public void setMaxCachedFiles(int maxCachedFiles) Set the max number of cached files..- Parameters:
maxCachedFiles
- the max number of cached files.
-
isUseDirectByteBuffers
public boolean isUseDirectByteBuffers() -
setUseDirectByteBuffers
public void setUseDirectByteBuffers(boolean useDirectByteBuffers) -
removeFromCache
-
flushCache
public void flushCache() -
isCacheable
Tests whether the given HttpContent is cacheable, and if there is enough room to fit it in the cache.- Parameters:
httpContent
- the HttpContent to test.- Returns:
- whether the HttpContent is cacheable.
-
getContent
- Specified by:
getContent
in interfaceHttpContent.Factory
- Parameters:
path
- The path within the context to the resource- Returns:
- A
HttpContent
- Throws:
IOException
- if unable to get content
-
newCachedContent
protected CachingHttpContentFactory.CachingHttpContent newCachedContent(String p, HttpContent httpContent) -
newNotFoundContent
-