I'm adding a configuration option to the CompositeCacheAttributes. It's called DiskUsagePattern. There are two patterns: update and swap. The changes are isolated to the CompositeCache class and they are very easy to unit test.
SWAP is the default. Under the swap pattern, data is only put to disk when the max memory size is reached. Since items puled from disk are put into memory, if the memory cache is full and you get an item off disk, the lest recently used item will be spooled to disk. If you have a low memory hit ration, you end up thrashing.
The UPDATE usage pattern allows items to go to disk on an update. It disables the swap. This allows you to persist all items to disk. If you are using the JDBC disk cache for instance, you can get all item on disk use the memory cache for performance, and not worry aobut lossing data on a system crash or improper shutdown. Also, since all items are on disk, there is no need to swap to disk. This prevents the possibility of threashing.
The configuration is done at the region level. The attrribute is called DiskUsagePatternName and takes two values: SWAP and UPDATE.
For example, below there is a region defined called "Swap" that uses the SWAP disk usage pattern and another called "Update" that uses the UPDATE usage pattern.
- CACHE REGIONS FOR TEST