/**
+ * Cache object max size in KB.
+ */
+ protected int cacheObjectMaxSize = 512; // 512K
+
+
+ /**
* Cache TTL in ms.
*/
protected int cacheTTL = 5000;
/**
+ * Return the maximum size of objects to be cached in KB.
+ */
+ public int getCacheObjectMaxSize() {
+ return cacheObjectMaxSize;
+ }
+
+
+ /**
+ * Set the maximum size of objects to be placed the cache in KB.
+ */
+ public void setCacheObjectMaxSize(int cacheObjectMaxSize) {
+ this.cacheObjectMaxSize = cacheObjectMaxSize;
+ }
+
+
+ /**
* Return the "follow standard delegation model" flag used to configure
* our ClassLoader.
*/
((BaseDirContext) resources).setCached(isCachingAllowed());
((BaseDirContext) resources).setCacheTTL(getCacheTTL());
((BaseDirContext) resources).setCacheMaxSize(getCacheMaxSize());
+ ((BaseDirContext) resources).setCacheObjectMaxSize(
+ getCacheObjectMaxSize());
}
if (resources instanceof FileDirContext) {
filesystemBased = true;
description="Maximum cache size in KB"
type="int"/>
+ <attribute name="cacheObjectMaxSize"
+ description="Maximum cached object size in KB"
+ type="int"/>
+
<attribute name="cacheTTL"
description="Time interval in ms between cache refeshes"
type="int"/>
/**
- * Max size of resources which will have their content cached.
+ * Max size of cache for resources.
*/
protected int cacheMaxSize = 10240; // 10 MB
+ /**
+ * Max size of resources that will be content cached.
+ */
+ protected int cacheObjectMaxSize = 512; // 512 K
+
+
// ------------------------------------------------------------- Properties
}
+ /**
+ * Return the maximum size of objects to be cached in KB.
+ */
+ public int getCacheObjectMaxSize() {
+ return cacheObjectMaxSize;
+ }
+
+
+ /**
+ * Set the maximum size of objects to be placed the cache in KB.
+ */
+ public void setCacheObjectMaxSize(int cacheObjectMaxSize) {
+ this.cacheObjectMaxSize = cacheObjectMaxSize;
+ }
+
+
// --------------------------------------------------------- Public Methods
}
cache.setCacheMaxSize(baseDirContext.getCacheMaxSize());
cacheTTL = baseDirContext.getCacheTTL();
- cacheObjectMaxSize = baseDirContext.getCacheMaxSize() / 20;
+ cacheObjectMaxSize = baseDirContext.getCacheObjectMaxSize();
+ // cacheObjectMaxSize must be less than cacheMaxSize
+ // Set a sensible limit
+ if (cacheObjectMaxSize > baseDirContext.getCacheMaxSize()/20) {
+ cacheObjectMaxSize = baseDirContext.getCacheMaxSize()/20;
+ }
}
}
hostName = (String) env.get(HOST);
(10 megabytes).</p>
</attribute>
+ <attribute name="cacheObjectMaxSize" required="false">
+ <p>Maximum size of the static resource that will be placed in the cache.
+ If not specified, the default value is <code>512</code>
+ (512 kilobytes). If this value is greater than
+ <code>cacheMaxSize/20</code> it will be reduced to
+ <code>cacheMaxSize/20</code>.</p>
+ </attribute>
+
<attribute name="cacheTTL" required="false">
<p>Amount of time in milliseconds between cache entries revalidation.
If not specified, the default value is <code>5000</code>