JCS 2.2 - How to set max size of memory/index disk cache?

773 views Asked by At

I'm using JCS to create a cache with LRU Memory Cache and the Indexed Disk Cache. I realize that there are properties like MaxObjects and maxKeySize that allow me to set the amount of items in a certain cache, but I'm wondering if JCS allows me to set the size in terms of how many KB, MB, GB, etc. each cache uses overall?

The Apache Commons JCS site references a KeySize attribute for the indexed disk cache here, but when I try to set that attribute in my cache.ccf, I'm told that there's "No such property [keySize] in org.apache.commons.jcs.auxiliary.disk.indexed.IndexedDiskCacheAttributes."

Does anyone know if JCS allows this?

1

There are 1 answers

0
Scott Johnson On BEST ANSWER

As of 2.2, the property for disk cache size limiting appears to be jcs.auxiliary.DC.attributes.MaxKeySize. Example configuration:

jcs.default=JC
jcs.auxiliary.DC=org.apache.commons.jcs.auxiliary.disk.indexed.IndexedDiskCacheFactory
jcs.auxiliary.DC.attributes=org.apache.commons.jcs.auxiliary.disk.indexed.IndexedDiskCacheAttributes
jcs.auxiliary.DC.attributes.DiskPath=cache
jcs.auxiliary.DC.attributes.DiskLimitType=SIZE
#Disk limit size in KB- 1 GB
jcs.auxiliary.DC.attributes.MaxKeySize=1000000

Unfortunately, as far as I can tell there's no parallel for the in-memory cache.