Class L1L2CacheProcessor
java.lang.Object
org.frontcache.cache.CacheProcessorBase
org.frontcache.cache.impl.L1L2CacheProcessor
- All Implemented Interfaces:
CacheProcessor
Cache processor based on
L1 - ehCache.
L2 - Apache Lucene.
-
Field Summary
Fields inherited from class CacheProcessorBase
softInvalidationExecutorFields inherited from interface CacheProcessor
CACHE_FOREVER, CACHED_ENTRIES, NO_CACHE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbackup()Backs up the L2 (Lucene) index to a sibling directory of the index dir.voiddestroy()getCachedKeys(int limit) At mostlimitcached keys, in no particular order - for a caller that samples the key space (the cache warmer's key-base check) rather than listing it.Read from the live Ehcache and the live IndexWriter - no reader opened, no directory rescanned beyond a file listing.getFromCacheImpl(String url) Load web-response from filevoidinit(Properties properties) voidpatch()voidpurge()Removes expired entries from both cache tiers: L1 (ehCache) is scanned in-memory; L2 (Lucene) is purged via a range query.voidputToCacheImpl(String url, WebResponse component) Saves web response to cache-filevoidremoveFromCache(String filter) voidRemoves every entry from this node.Methods inherited from class CacheProcessorBase
doSoftInvalidation, getFromCache, processRequest, putToCacheMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface CacheProcessor
doSoftInvalidation, getFromCache, processRequest, putToCache
-
Constructor Details
-
L1L2CacheProcessor
public L1L2CacheProcessor()
-
-
Method Details
-
init
- Specified by:
initin interfaceCacheProcessor- Overrides:
initin classCacheProcessorBase
-
destroy
public void destroy()- Specified by:
destroyin interfaceCacheProcessor- Overrides:
destroyin classCacheProcessorBase
-
putToCacheImpl
Saves web response to cache-file- Specified by:
putToCacheImplin classCacheProcessorBase- Parameters:
url- cache keycomponent- response to store - the cache takes ownership of it
-
getFromCacheImpl
Load web-response from file- Specified by:
getFromCacheImplin classCacheProcessorBase
-
removeFromCache
- Specified by:
removeFromCachein interfaceCacheProcessor
-
removeFromCacheAll
public void removeFromCacheAll()Description copied from interface:CacheProcessorRemoves every entry from this node. There used to be a domain-scoped flavour alongside this one. It only dropped entries stamped with the caller's domain, and replicated entries carry the domain of the edge they came from - so an "invalidate all" at the target edge walked straight past them and they stayed served. With one site per node there is one flavour, and it means what it says.- Specified by:
removeFromCacheAllin interfaceCacheProcessor
-
getCacheStatus
- Specified by:
getCacheStatusin interfaceCacheProcessor- Overrides:
getCacheStatusin classCacheProcessorBase
-
getCacheStats
Read from the live Ehcache and the live IndexWriter - no reader opened, no directory rescanned beyond a file listing. Every number is defensive: this feeds gauges, and a wedged L2 index must degrade to "unknown" rather than break a scrape.- Specified by:
getCacheStatsin interfaceCacheProcessor
-
getCachedKeys
- Specified by:
getCachedKeysin interfaceCacheProcessor
-
getCachedKeys
Description copied from interface:CacheProcessorAt mostlimitcached keys, in no particular order - for a caller that samples the key space (the cache warmer's key-base check) rather than listing it. Adefaultbecause it is additive: a processor that does not override it answers fromCacheProcessor.getCachedKeys(), which is correct and merely as expensive as it always was. The built-in L1/L2 processor overrides it to stop reading the index once it has enough.- Specified by:
getCachedKeysin interfaceCacheProcessor
-
patch
public void patch()- Specified by:
patchin interfaceCacheProcessor
-
purge
public void purge()Removes expired entries from both cache tiers: L1 (ehCache) is scanned in-memory; L2 (Lucene) is purged via a range query. "Cache forever" entries are never removed.- Specified by:
purgein interfaceCacheProcessor
-
backup
Backs up the L2 (Lucene) index to a sibling directory of the index dir. L1 (ehCache) is in-memory and not backed up.- Specified by:
backupin interfaceCacheProcessor- Returns:
- the name of the created backup directory
-