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
Nested ClassesModifier and TypeClassDescriptionprotected classprotected static interfaceprotected static class -
Constructor Summary
ConstructorsConstructorDescriptionCachingHttpContentFactory(HttpContent.Factory authority, ByteBufferPool bufferPool) -
Method Summary
Modifier and TypeMethodDescriptionvoidgetCache()intlonggetContent(String path) intGet the max number of cached files..intlongprotected booleanisCacheable(HttpContent httpContent) Tests whether the given HttpContent is cacheable, and if there is enough room to fit it in the cache.booleannewCachedContent(String p, HttpContent httpContent) protected voidvoidsetMaxCachedFiles(int maxCachedFiles) Set the max number of cached files..voidsetMaxCachedFileSize(int maxCachedFileSize) voidsetMaxCacheSize(long maxCacheSize) voidsetUseDirectByteBuffers(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:
getContentin 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
-