使用“Inline Refresh Ahead”,如:http://terracotta.org/documentation/4.1/bigmemorymax/api/refresh-ahead#scheduled-refresh-ahead 所述
我将缓存条目更新为:
<?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>
但我收到错误:
元素不允许嵌套元素。
看来我添加的 cacheDecorator 不正确?
最佳答案
如果您查看 the documentation (参见@alain.janinm 的评论)和the XSD它说
....
<xs:element name="cache">
<xs:complexType>
<xs:sequence>
...
<xs:element minOccurs="0" maxOccurs="unbounded"
ref="cacheDecoratorFactory"/>
^^^^^^^
所以,你的问题是打字错误 - 更改
<cacheDecorator class="net.sf.ehcache....
到
<cacheDecoratorFactory class="net.sf.ehcache....
你会没事的。
干杯,
关于java - 无法将 cacheDecorator 添加到 ehcache,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26803277/