Class L1L2CacheProcessor

java.lang.Object
org.frontcache.cache.CacheProcessorBase
org.frontcache.cache.impl.L1L2CacheProcessor
All Implemented Interfaces:
CacheProcessor

public class L1L2CacheProcessor extends CacheProcessorBase implements CacheProcessor
Cache processor based on L1 - ehCache. L2 - Apache Lucene.
  • Constructor Details

    • L1L2CacheProcessor

      public L1L2CacheProcessor()
  • Method Details

    • init

      public void init(Properties properties)
      Specified by:
      init in interface CacheProcessor
      Overrides:
      init in class CacheProcessorBase
    • destroy

      public void destroy()
      Specified by:
      destroy in interface CacheProcessor
      Overrides:
      destroy in class CacheProcessorBase
    • putToCacheImpl

      public void putToCacheImpl(String url, WebResponse component)
      Saves web response to cache-file
      Specified by:
      putToCacheImpl in class CacheProcessorBase
      Parameters:
      url - cache key
      component - response to store - the cache takes ownership of it
    • getFromCacheImpl

      public WebResponse getFromCacheImpl(String url)
      Load web-response from file
      Specified by:
      getFromCacheImpl in class CacheProcessorBase
    • removeFromCache

      public void removeFromCache(String filter)
      Specified by:
      removeFromCache in interface CacheProcessor
    • removeFromCacheAll

      public void removeFromCacheAll()
      Description copied from interface: CacheProcessor
      Removes 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:
      removeFromCacheAll in interface CacheProcessor
    • getCacheStatus

      public Map<String,String> getCacheStatus()
      Specified by:
      getCacheStatus in interface CacheProcessor
      Overrides:
      getCacheStatus in class CacheProcessorBase
    • getCacheStats

      public CacheStats 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:
      getCacheStats in interface CacheProcessor
    • getCachedKeys

      public List<String> getCachedKeys()
      Specified by:
      getCachedKeys in interface CacheProcessor
    • getCachedKeys

      public List<String> getCachedKeys(int limit)
      Description copied from interface: CacheProcessor
      At most limit cached keys, in no particular order - for a caller that samples the key space (the cache warmer's key-base check) rather than listing it. A default because it is additive: a processor that does not override it answers from CacheProcessor.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:
      getCachedKeys in interface CacheProcessor
    • patch

      public void patch()
      Specified by:
      patch in interface CacheProcessor
    • 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:
      purge in interface CacheProcessor
    • backup

      public String 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:
      backup in interface CacheProcessor
      Returns:
      the name of the created backup directory