Search code examples
javahibernateehcache

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


Solution

  • 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