Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

EhCache overflow to disk at specific path

I am using ehcache with hibernate in my application. here is configuration of ehcache.xml

<ehcache>
    <diskStore path="java.io.tmpdir"/>        

    <defaultCache
            maxElementsInMemory="10"
            eternal="false"
            timeToIdleSeconds="120"
            timeToLiveSeconds="120"
            overflowToDisk="true"
            diskSpoolBufferSizeMB="300"
            maxElementsOnDisk="10000000"
            diskPersistent="false"
            diskExpiryThreadIntervalSeconds="120"
            memoryStoreEvictionPolicy="LRU"
            />
</ehcache>

my diskStore path is java.io.tmpdir, which i want to change to my application path as ${WebApp}/DiskStore

like image 286
Rahul Agrawal Avatar asked Jul 19 '12 11:07

Rahul Agrawal


People also ask

Is Ehcache persistent?

Open-source Ehcache offers a limited version of persistence, as noted in this document. Fast Restart provides enterprise-ready crash resilience with an option to store a fully consistent copy of the cache on the local disk at all times.

Where does Ehcache store data?

All the data is kept in the authority tier, which is slower but more abundant. Data stores supported by Ehcache include: On-Heap Store - Utilizes Java's on-heap RAM memory to store cache entries. This tier utilizes the same heap memory as your Java application, all of which must be scanned by the JVM garbage collector.

What is overflowToDisk in Ehcache?

ehcache. overflowToDisk — Sets whether the disk store persists to disk between restarts of the Java Virtual Machine. The default value is true.

Is Ehcache in memory?

Overview. In this article, we will introduce Ehcache, a widely used, open-source Java-based cache. It features memory and disk stores, listeners, cache loaders, RESTful and SOAP APIs and other very useful features.


1 Answers

Storage Location are specified by hard coading paths.

Legal values for the path attibute are legal file system paths.

E.g., for Unix: /home/application/cache

The following system properties are also legal, in which case they are translated:

user.home - User's home directory
user.dir - User's current working directory
java.io.tmpdir - Default temp file path
ehcache.disk.store.dir - A system property 

Subdirectories can be specified below the system property, for example:

java.io.tmpdir/one

becomes, on a Unix system:

/tmp/one

like image 91
NPKR Avatar answered Oct 17 '22 20:10

NPKR