Class ValidatingCachingHttpContentFactory
- All Implemented Interfaces:
Runnable
,HttpContent.Factory
HttpContent.Factory
implementation of CachingHttpContentFactory
which evicts invalid entries from the cache.
Uses a validationTime parameter to check files when they are accessed and/or sweepDelay parameter for a periodic sweep
for invalid entries in the cache.
HttpContent
validation checks are configured through the validationTime
parameter in the constructor.
If an HttpContent
is found to be invalid it will be removed from the cache.
A value of -1 means that the cached HttpContent
will never be checked if it is still valid,
a value of 0 means it is checked on every request,
a positive value indicates the number of milliseconds of the minimum time between validation checks.
This also remember a missed entry for the time set by validationTime
ms. After this has
elapsed the entry will be invalid and will be evicted from the cache at the next access.
-
Nested Class Summary
Modifier and TypeClassDescriptionprotected class
protected static class
Nested classes/interfaces inherited from class org.eclipse.jetty.http.content.CachingHttpContentFactory
CachingHttpContentFactory.CachedHttpContent, CachingHttpContentFactory.CachingHttpContent, CachingHttpContentFactory.NotFoundHttpContent
-
Constructor Summary
ConstructorDescriptionValidatingCachingHttpContentFactory
(HttpContent.Factory authority, long validationPeriod, ByteBufferPool bufferPool) Construct aValidatingCachingHttpContentFactory
which validates entries upon use to check if they are still valid.ValidatingCachingHttpContentFactory
(HttpContent.Factory authority, long validationPeriod, ByteBufferPool bufferPool, Scheduler scheduler, long sweepPeriod, long idleTimeout) Construct aValidatingCachingHttpContentFactory
which validates entries upon use to check if they are still valid and an optional period sweeper of the cache to find invalid and old entries to evict. -
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
isCacheable
(HttpContent httpContent) Tests whether the given HttpContent is cacheable, and if there is enough room to fit it in the cache.newCachedContent
(String p, HttpContent httpContent) void
run()
Methods inherited from class org.eclipse.jetty.http.content.CachingHttpContentFactory
flushCache, getCache, getCachedFiles, getCachedSize, getContent, getMaxCachedFiles, getMaxCachedFileSize, getMaxCacheSize, isUseDirectByteBuffers, removeFromCache, setMaxCachedFiles, setMaxCachedFileSize, setMaxCacheSize, setUseDirectByteBuffers
-
Constructor Details
-
ValidatingCachingHttpContentFactory
public ValidatingCachingHttpContentFactory(@Name("authority") HttpContent.Factory authority, @Name("validationPeriod") long validationPeriod, @Name("bufferPool") ByteBufferPool bufferPool) Construct aValidatingCachingHttpContentFactory
which validates entries upon use to check if they are still valid.- Parameters:
authority
- the wrappedHttpContent.Factory
to use.validationPeriod
- time between filesystem checks in ms to see if anHttpContent
is still valid (-1 never validate, 0 always validate).bufferPool
- theByteBufferPool
to use.
-
ValidatingCachingHttpContentFactory
public ValidatingCachingHttpContentFactory(@Name("authority") HttpContent.Factory authority, @Name("validationPeriod") long validationPeriod, @Name("byteBufferPool") ByteBufferPool bufferPool, @Name("scheduler") Scheduler scheduler, @Name("sweepPeriod") long sweepPeriod, @Name("idleTimeout") long idleTimeout) Construct aValidatingCachingHttpContentFactory
which validates entries upon use to check if they are still valid and an optional period sweeper of the cache to find invalid and old entries to evict.- Parameters:
authority
- the wrappedHttpContent.Factory
to use.validationPeriod
- time between filesystem checks in ms to see if anHttpContent
is still valid (-1 never validate, 0 always validate).bufferPool
- theByteBufferPool
to use.scheduler
- scheduler to use for the sweeper, can be null to not use sweeper.sweepPeriod
- time between runs of the sweeper in ms (if 0 never sweep for invalid entries).idleTimeout
- amount of time in ms an entry can be unused before evicted by the sweeper (if 0 never evict unused entries).
-
-
Method Details
-
isCacheable
Description copied from class:CachingHttpContentFactory
Tests whether the given HttpContent is cacheable, and if there is enough room to fit it in the cache.- Overrides:
isCacheable
in classCachingHttpContentFactory
- Parameters:
httpContent
- the HttpContent to test.- Returns:
- whether the HttpContent is cacheable.
-
run
public void run() -
newCachedContent
protected CachingHttpContentFactory.CachingHttpContent newCachedContent(String p, HttpContent httpContent) - Overrides:
newCachedContent
in classCachingHttpContentFactory
-
newNotFoundContent
- Overrides:
newNotFoundContent
in classCachingHttpContentFactory
-