Unable to add cacheDecorator to ehcache

故事扮演 提交于 2020-01-05 05:12:31

问题


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 ?


回答1:


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,



来源:https://stackoverflow.com/questions/26803277/unable-to-add-cachedecorator-to-ehcache

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!