The cache implementation in the module
urn:org:ten60:netkernel:cache:standard
is configured by default
to be relatively self tuning.
It uses soft references to maximise use of available memory whilst keeping as many items available
as possible.
The cache operates by using a soft reference to lower value items
making them
eligible for garbage collection as heap space becomes limited.
The following parameters are tunable:
-
Recompute Period
The cache requires periodic housekeeping to prune expired items, move low value items to soft references and
collect statistics. This value determines the number of 'cache puts' between recomputations of cache state.
-
Soft Threshold
The hard-soft threshold value per Megabyte of available (GC Baseline) heap.
This value is multiplied by
available heap to give the cacheability index above which cache items will be turned into soft references and
will then become available for garbage collection.
A larger value will increase the cacheable lifetime of
resources at the expense of larger memory footprint.
-
Hard Limit
Only lower this value if you cannot successfully regulate memory usage with softThreshold. The maximum number
of items the cache will keep as hard references regardless of perceived memory availability. This value should
be used as a safety valve. It ensures that in very dynamic situations the memory usage of the cache cannot
grow unbounded but when the valve is opened the cache becomes less efficient.
For additional control over the behaviour of soft references see documentation on
SoftRefLRUPolicyMSPerMB
when running on Sun JVMs.