blue-sky
blue-sky

Reputation: 53806

Unable to add cacheDecorator to ehcache

Using "Inline Refresh Ahead" as described at : http://terracotta.org/documentation/4.1/bigmemorymax/api/refresh-ahead#scheduled-refresh-ahead

I updated my cache entry to :

   <?xml version="1.0" encoding="UTF-8"?>
<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:noNamespaceSchemaLocation="http://ehcache.org/ehcache.xsd">
    <defaultCache eternal="true" maxElementsInMemory="100"
        overflowToDisk="false" />
    <cache name="myCache" maxElementsInMemory="10000" eternal="true"
        overflowToDisk="false">

        <cacheDecorator
            class="net.sf.ehcache.constructs.refreshahead.RefreshAheadCacheFactory"
            properties="name=myCacheRefresher,
      timeToRefreshSeconds=200,
      batchSize=10,
      numberOfThreads=4,
      maximumBacklogItems=100,
      evictOnLoadMiss=true" />

    </cache>
</ehcache>

But I receive error :

Element does not allow nested elements.

So it seems that I have added the cacheDecorator incorrectly ?

Upvotes: 1

Views: 246

Answers (1)

Anders R. Bystrup
Anders R. Bystrup

Reputation: 16060

If you look in the documentation (cf. @alain.janinm's comment) and the XSD it says

....
<xs:element name="cache">
    <xs:complexType>
        <xs:sequence>
            ...
            <xs:element minOccurs="0" maxOccurs="unbounded"
                        ref="cacheDecoratorFactory"/>
                                           ^^^^^^^

So, your problem is a typo - change

<cacheDecorator class="net.sf.ehcache....

to

<cacheDecoratorFactory class="net.sf.ehcache....

and you will be fine.

Cheers,

Upvotes: 4

Related Questions