I'm using ColdFusion 9 with Ehcache
Ehcache was working pretty well but since I re-installed my machine Ehcache.Cache.put
refuse to work on a specific element but is working on tons of other elements.
Cache.put
throws no exception and takes about 4 seconds to return.
The element I try to put in cache is a ColdFusion component and is only about 7ko. I don't use serialization.
The cache configuration is:
<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://ehcache.org/ehcache.xsd"
maxBytesLocalHeap="300m">
<sizeOfPolicy maxDepth="99999999" maxDepthExceededBehavior="continue"/>
<defaultCache
eternal="false"
timeToIdleSeconds="300"
timeToLiveSeconds="1200"
overflowToDisk="false"
statistics="true">
I changed it to
<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://ehcache.org/ehcache.xsd"
maxEntriesLocalHeap="900">
<defaultCache
eternal="false"
timeToIdleSeconds="300"
timeToLiveSeconds="1200"
overflowToDisk="false"
statistics="true"
maxEntriesLocalHeap="100">
And this works! Changing from a maxBytesLocalHeap
to a maxEntriesLocalHeap
config makes the difference! I think maybe the internal size calculation is not working. Using maxEntriesLocalHeap
do not require size calculation that's why it works with the new configuration.
So why:
Cache.put
not working with maxBytesLocalHeap
on only one specific
element?Cache.put
function takes 4 seconds?If you have any clue, please let me know.
I really need to switch back to maxBytesLocalHeap
.
PS:
Ehcache sizing of a ColdFusion element go too deep and process every Java underlying objects like ColdFusion frameworks objets, etc...
I fixed my issue by setting a filter. I use the system property net.sf.ehcache.sizeof.filter
which points to text file location containing FQCN or fields for the sizing engine to ignore. Source: http://forums.terracotta.org/forums/posts/list/6371.page
I set net.sf.ehcache.sizeof.filter
by starting Java VM with -D
argument like that:
-D net.sf.ehcache.sizeof.filter=/My/Path/To/File.config
My filter configuration file contains:
coldfusion.runtime.NeoPageContext
coldfusion.runtime.CfJspPage
coldfusion.monitor.memory.MemoryTrackable
coldfusion.monitor.sql.QueryStat
coldfusion.monitor.memory.MemoryTrackerProxy
javax.servlet.ServletContext