Class Cache
java.lang.Object
org.apache.catalina.webresources.Cache
Cache for web resources managed by a StandardRoot.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final StringManagerString manager for internationalized messages. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidPerforms background cache maintenance, evicting expired entries.voidclear()Clears all entries from the cache.Returns the cache strategy.longReturns the total number of cache hits.longReturns the total number of cache lookups.longReturns the maximum cache size in kilobytes.intReturns the maximum size of a single cached object in kilobytes.intReturns the maximum size of a single cached object in bytes.protected WebResourcegetResource(String path, boolean useClassLoaderResources) Retrieves a single resource from the cache.protected WebResource[]getResources(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 Details
-
sm
String manager for internationalized messages.
-
-
Constructor Details
-
Cache
Constructs a cache for the given root.- Parameters:
root- the standard root
-
-
Method Details
-
getResource
Retrieves a single resource from the cache.- Parameters:
path- resource pathuseClassLoaderResources- whether to use class loader resources- Returns:
- the web resource
-
getResources
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
Returns the cache strategy.- Returns:
- the cache strategy
-
setCacheStrategy
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
-