Package org.apache.catalina.webresources
Class Cache
- java.lang.Object
-
- org.apache.catalina.webresources.Cache
-
public class Cache extends java.lang.ObjectCache for web resources managed by a StandardRoot.
-
-
Field Summary
Fields Modifier and Type Field Description protected static StringManagersmString manager for internationalized messages.
-
Constructor Summary
Constructors Constructor Description Cache(StandardRoot root)Constructs a cache for the given root.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidbackgroundProcess()Performs background cache maintenance, evicting expired entries.voidclear()Clears all entries from the cache.WebResourceRoot.CacheStrategygetCacheStrategy()Returns the cache strategy.longgetHitCount()Returns the total number of cache hits.longgetLookupCount()Returns the total number of cache lookups.longgetMaxSize()Returns the maximum cache size in kilobytes.intgetObjectMaxSize()Returns the maximum size of a single cached object in kilobytes.intgetObjectMaxSizeBytes()Returns the maximum size of a single cached object in bytes.protected WebResourcegetResource(java.lang.String path, boolean useClassLoaderResources)Retrieves a single resource from the cache.protected WebResource[]getResources(java.lang.String path, boolean useClassLoaderResources)Retrieves multiple resources from the cache.longgetSize()Returns the current cache size in kilobytes.longgetTtl()Returns the time-to-live for cached entries.voidsetCacheStrategy(WebResourceRoot.CacheStrategy cacheStrategy)Sets the cache strategy.voidsetMaxSize(long maxSize)Sets the maximum cache size in kilobytes.voidsetObjectMaxSize(int objectMaxSize)Sets the maximum size of a single cached object in kilobytes.voidsetTtl(long ttl)Sets the time-to-live for cached entries.
-
-
-
Field Detail
-
sm
protected static final StringManager sm
String manager for internationalized messages.
-
-
Constructor Detail
-
Cache
public Cache(StandardRoot root)
Constructs a cache for the given root.- Parameters:
root- the standard root
-
-
Method Detail
-
getResource
protected WebResource getResource(java.lang.String path, boolean useClassLoaderResources)
Retrieves a single resource from the cache.- Parameters:
path- resource pathuseClassLoaderResources- whether to use class loader resources- Returns:
- the web resource
-
getResources
protected WebResource[] getResources(java.lang.String path, boolean useClassLoaderResources)
Retrieves multiple resources from the cache.- Parameters:
path- resource pathuseClassLoaderResources- 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
-
-