Class Cache

java.lang.Object
org.apache.catalina.webresources.Cache

public class Cache extends Object
Cache for web resources managed by a StandardRoot.
  • Field Details

    • sm

      protected static final StringManager sm
      String manager for internationalized messages.
  • Constructor Details

    • Cache

      public Cache(StandardRoot root)
      Constructs a cache for the given root.
      Parameters:
      root - the standard root
  • Method Details

    • getResource

      protected WebResource getResource(String path, boolean useClassLoaderResources)
      Retrieves a single resource from the cache.
      Parameters:
      path - resource path
      useClassLoaderResources - whether to use class loader resources
      Returns:
      the web resource
    • getResources

      protected WebResource[] getResources(String path, boolean useClassLoaderResources)
      Retrieves multiple resources from the cache.
      Parameters:
      path - resource path
      useClassLoaderResources - whether to use class loader resources
      Returns:
      the web resources
    • backgroundProcess

      protected void backgroundProcess()
      Performs background cache maintenance, evicting expired entries.
    • getCacheStrategy

      public WebResourceRoot.CacheStrategy getCacheStrategy()
      Returns the cache strategy.
      Returns:
      the cache strategy
    • setCacheStrategy

      public void setCacheStrategy(WebResourceRoot.CacheStrategy cacheStrategy)
      Sets the cache strategy.
      Parameters:
      cacheStrategy - the cache strategy
    • getTtl

      public long getTtl()
      Returns the time-to-live for cached entries.
      Returns:
      the TTL in milliseconds
    • setTtl

      public void setTtl(long ttl)
      Sets the time-to-live for cached entries.
      Parameters:
      ttl - the TTL in milliseconds
    • getMaxSize

      public long getMaxSize()
      Returns the maximum cache size in kilobytes.
      Returns:
      the maximum size in KB
    • setMaxSize

      public void setMaxSize(long maxSize)
      Sets the maximum cache size in kilobytes.
      Parameters:
      maxSize - the maximum size in KB
    • getLookupCount

      public long getLookupCount()
      Returns the total number of cache lookups.
      Returns:
      the lookup count
    • getHitCount

      public long getHitCount()
      Returns the total number of cache hits.
      Returns:
      the hit count
    • setObjectMaxSize

      public void setObjectMaxSize(int objectMaxSize)
      Sets the maximum size of a single cached object in kilobytes.
      Parameters:
      objectMaxSize - the maximum object size in KB
    • getObjectMaxSize

      public int getObjectMaxSize()
      Returns the maximum size of a single cached object in kilobytes.
      Returns:
      the maximum object size in KB
    • getObjectMaxSizeBytes

      public int getObjectMaxSizeBytes()
      Returns the maximum size of a single cached object in bytes.
      Returns:
      the maximum object size in bytes
    • clear

      public void clear()
      Clears all entries from the cache.
    • getSize

      public long getSize()
      Returns the current cache size in kilobytes.
      Returns:
      the current size in KB