grails3ehcache-3

valid ehcache.xml using ehcache3 plugin for grails3


grails version 3.3.1 cache-ehcache:3.0.0.M1

can somebody send me a valid ehcache.xmlplease?

My file looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:noNamespaceSchemaLocation="ehcache.xsd"
     updateCheck="true"
     monitoring="autodetect"
     dynamicConfig="true">

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

    <cache name="sevenSeconds"
       maxEntriesLocalHeap="100"
       maxEntriesLocalDisk="1000"
       eternal="false"
       timeToLiveSeconds="7"
       timeToIdleSeconds="0"
       memoryStoreEvictionPolicy="LFU"
       transactionalMode="off">
       <persistence strategy="localTempSwap" />
    </cache>

    <defaultCache
        maxElementsInMemory="50000"
        eternal="false"
        timeToIdleSeconds="120"
        timeToLiveSeconds="120"
        overflowToDisk="true"
        diskPersistent="false"
        diskExpiryThreadIntervalSeconds="120"
        memoryStoreEvictionPolicy="LRU"
    />
</ehcache>

and i get this error while startup:

Caused by: org.ehcache.xml.exceptions.XmlConfigurationException: Error parsing XML configuration at file:/home/user/workspaces/api2-grails/grails-app/conf/ehcacheCustom.xml
Caused by: org.xml.sax.SAXParseException: cvc-elt.1.a: Cannot find the declaration of element 'ehcache'.

thanks for suggestions


Solution

  • After struggling with the same issue I found this link and just took it as a base to get the following working example:

    <ehcache:config xmlns:ehcache="http://www.ehcache.org/v3" xmlns:jcache="http://www.ehcache.org/v3/jsr107">
        <ehcache:cache alias="books">
            <ehcache:key-type>java.lang.String</ehcache:key-type>
            <ehcache:value-type>hello.Book</ehcache:value-type>
            <ehcache:resources>
                <ehcache:heap unit="MB">1</ehcache:heap>
                <!--ehcache:offheap unit="MB">10</ehcache:offheap-->
            </ehcache:resources>
        </ehcache:cache>
    </ehcache:config>