ehcache 3.4.0 and heap and offheap config using system variable

80 views
Skip to first unread message

Upendra Singh

unread,
Oct 4, 2023, 7:26:00 AM10/4/23
to ehcache-users
Hi Team,

We are using ehcache 3.4.0.

And also using ehcache.xml for cache declaration and related mapping. We have below config for heap and offheap config. 

<ehcache:cache alias="ENQUIRY">
<ehcache:key-type>java.lang.String</ehcache:key-type>
<ehcache:resources>
<ehcache:heap unit="entries">200</ehcache:heap>
<ehcache:offheap unit="MB">2</ehcache:offheap>
</ehcache:resources>
</ehcache:cache>

Since this value is hardcoded , we required to change this as conditional environment variable to set required value.

I tried replacing with  below,

<ehcache:cache alias="ENQUIRY">
<ehcache:key-type>java.lang.String</ehcache:key-type>
<ehcache:resources>
           <ehcache:heap unit="entries">${if:${iris.cache.heap.entries} is null then:100 else:${iris.cache.heap.entries}}</ehcache:heap>
           <ehcache:offheap unit="MB">${if:${iris.cache.offheap.size} is null then:1 else:${iris.cache.offheap.size}}</ehcache:offheap>

</ehcache:resources>
</ehcache:cache>

But its ended with below error,
javax.cache.CacheException: org.ehcache.xml.exceptions.XmlConfigurationException: Error parsing XML configuration at vfs:/C:/Work/ReleasedUTP/UTP-REL-R23-RET-2023.05.25/Tem/jboss/bin/content/irf-test-web.war/WEB-INF/lib/irf-cache-23.0.0.jar/ehcache.xml

Please help with right syntax.

Regards,
Upendra
Reply all
Reply to author
Forward
0 new messages