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 validationTimems. After this has
elapsed the entry will be invalid and will be evicted from the cache at the next access.
- 
Nested Class SummaryNested ClassesModifier and TypeClassDescriptionprotected classprotected static classNested classes/interfaces inherited from class CachingHttpContentFactoryCachingHttpContentFactory.CachedHttpContent, CachingHttpContentFactory.CachingHttpContent, CachingHttpContentFactory.NotFoundHttpContent
- 
Constructor SummaryConstructorsConstructorDescriptionValidatingCachingHttpContentFactory(HttpContent.Factory authority, long validationPeriod, ByteBufferPool bufferPool) Construct aValidatingCachingHttpContentFactorywhich 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 aValidatingCachingHttpContentFactorywhich 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 SummaryModifier and TypeMethodDescriptionprotected booleanisCacheable(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) voidrun()Methods inherited from class CachingHttpContentFactoryflushCache, getCache, getCachedFiles, getCachedSize, getContent, getMaxCachedFiles, getMaxCachedFileSize, getMaxCacheSize, isUseDirectByteBuffers, removeFromCache, setMaxCachedFiles, setMaxCachedFileSize, setMaxCacheSize, setUseDirectByteBuffers
- 
Constructor Details- 
ValidatingCachingHttpContentFactorypublic ValidatingCachingHttpContentFactory(@Name("authority") HttpContent.Factory authority, @Name("validationPeriod") long validationPeriod, @Name("bufferPool") ByteBufferPool bufferPool) Construct aValidatingCachingHttpContentFactorywhich validates entries upon use to check if they are still valid.- Parameters:
- authority- the wrapped- HttpContent.Factoryto use.
- validationPeriod- time between filesystem checks in ms to see if an- HttpContentis still valid (-1 never validate, 0 always validate).
- bufferPool- the- ByteBufferPoolto use.
 
- 
ValidatingCachingHttpContentFactorypublic 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 aValidatingCachingHttpContentFactorywhich 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 wrapped- HttpContent.Factoryto use.
- validationPeriod- time between filesystem checks in ms to see if an- HttpContentis still valid (-1 never validate, 0 always validate).
- bufferPool- the- ByteBufferPoolto 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- 
isCacheableDescription copied from class:CachingHttpContentFactoryTests whether the given HttpContent is cacheable, and if there is enough room to fit it in the cache.- Overrides:
- isCacheablein class- CachingHttpContentFactory
- Parameters:
- httpContent- the HttpContent to test.
- Returns:
- whether the HttpContent is cacheable.
 
- 
run
- 
newCachedContentprotected CachingHttpContentFactory.CachingHttpContent newCachedContent(String p, HttpContent httpContent) - Overrides:
- newCachedContentin class- CachingHttpContentFactory
 
- 
newNotFoundContent- Overrides:
- newNotFoundContentin class- CachingHttpContentFactory
 
 
-