Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to configure cache expiry to none and overflowToDisk="false" in ehcache 3.5 version?

Tags:

java

ehcache-3

In ehcache 2.x version I have following configuration.

<cache name="basicCache"
        maxEntriesLocalHeap="400"
        eternal="true"
        timeToIdleSeconds="0"
        timeToLiveSeconds="0"
        overflowToDisk="false">             
    </cache>

Following is the corresponding ehcache 3.x version.

<ehcache:cache alias="basicCache">
        <ehcache:key-type>java.lang.Long</ehcache:key-type>
    <ehcache:value-type>java.lang.String</ehcache:value-type>           
        <ehcache:resources>
            <ehcache:heap unit=entries">400</ehcache:heap>
        </ehcache:resources>    
    </ehcache:cache>

can someone help me to configure below attributes in ehcache 3.5.2 version.

eternal="true" and overflowToDisk="false"

like image 781
Madhuri Haritha Avatar asked Oct 18 '25 07:10

Madhuri Haritha


2 Answers

For setting eternal to true, which means the timeouts are ignored and cache will never expire. You can set this by setting expiry as none. Something like below,

<cache alias="backupCache">
    <key-type>java.lang.String</key-type>
    <value-type>java.lang.String</value-type>
    <expiry>
        <none/>
    </expiry>
    <resources>
        <heap unit="entries">100</heap>
    </resources>
</cache>

Hope this helps :)

like image 175
Hetal Rachh Avatar answered Oct 19 '25 22:10

Hetal Rachh


overflowToDisk concept has been removed from the ehcache 3.x version.Refer this link for more details

https://groups.google.com/forum/#!topic/ehcache-users/FFHHhRW5hdg

like image 21
Manikandaprabu.G Avatar answered Oct 19 '25 20:10

Manikandaprabu.G



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!