i have recently switched from an older implementation of ehcache to version 3.2 so i have the following xml configuration file for a project:
<eh:config xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
xmlns:eh='http://www.ehcache.org/v3'
xsi:schemaLocation="http://www.ehcache.org/v3
http://www.ehcache.org/schema/ehcache-core-3.0.xsd">
<eh:persistence directory="C:\foo\bar\Cache-Persistence"/>
<eh:thread-pools>
<eh:thread-pool alias="defaultDiskPool" min-size="1" max-size="3"/>
</eh:thread-pools>
<eh:disk-store thread-pool="defaultDiskPool"/>
<eh:cache-template name="PROC_REQTemplate">
<eh:key-type>java.lang.String</eh:key-type>
<eh:value-type>java.lang.String</eh:value-type>
<eh:expiry>
<eh:ttl>640</eh:ttl>
</eh:expiry>
<eh:resources>
<eh:offheap unit="MB">500</eh:offheap>
<eh:disk unit="GB" persistent="true">3</eh:disk>
</eh:resources>
<eh:disk-store-settings thread-pool="defaultDiskPool"/>
</eh:cache-template>
<eh:cache alias="proc_req_cache" uses-template="PROC_REQTemplate"/>
</eh:config>
with the above shown configuration i get the following exception trace that i keep truncated to conserve a bit of space but shows clearly the error:
java.lang.IllegalStateException: No Store.Provider found to handle configured resource types [offheap, disk] from {org.ehcache.impl.internal.store.heap.OnHeapStore$Provider, org.ehcache.impl.internal.store.tiering.TieredStore$Provider, org.ehcache.impl.internal.store.offheap.OffHeapStore$Provider, org.ehcache.impl.internal.store.disk.OffHeapDiskStore$Provider}
at org.ehcache.core.internal.store.StoreSupport.selectStoreProvider(StoreSupport.java:80) ~[?:?]
at org.ehcache.core.EhcacheManager.getStore(EhcacheManager.java:440) ~[?:?]
at org.ehcache.core.EhcacheManager.createNewEhcache(EhcacheManager.java:311) ~[?:?]
at org.ehcache.core.EhcacheManager.createCache(EhcacheManager.java:260) ~[?:?]
at org.ehcache.core.EhcacheManager.init(EhcacheManager.java:567) ~[?:?]
I thought that according to the current 3.2 documentation you can use any combination of data storage tiers but apparently this is not the case as the above error shows.So...
Any help would be greatly appreciated. Thanks in advance.
In short, there is currently no support for having a disk tier with just an offheap tier. The current Ehcache 3.x support for tiering mandates a heap tier the moment you want to have multiple tiers.
Supported combination at this day (Ehcache 3.1.x and above):
The error has nothing to do with BigMemory
which was the commercial offering on top of Ehcache 2.x.
The problem is that the higher caching level (currently offheap) needs to be a caching tier (our terminology for near caching). Right now, offheap isn't. So you need an onheap level as soon as you start having layers. Here is a working configuration.
I've also set ehcache
as default namespace to make the xml more readable. And set the defaultThreadPool
as default to prevent you from having to set it everywhere (and alternative is to add <event-dispatch thread-pool="defaultDiskPool"/>
because the event-dispatch needs a thread pool and there was no default).
<config xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
xmlns='http://www.ehcache.org/v3'
xsi:schemaLocation="http://www.ehcache.org/v3
http://www.ehcache.org/schema/ehcache-core-3.0.xsd">
<persistence directory="C:\foo\bar\Cache-Persistence"/>
<thread-pools>
<thread-pool alias="defaultDiskPool" min-size="1" max-size="3" default="true"/>
</thread-pools>
<cache-template name="PROC_REQTemplate">
<key-type>java.lang.String</key-type>
<value-type>java.lang.String</value-type>
<expiry>
<ttl>640</ttl>
</expiry>
<resources>
<heap unit="entries">1</heap>
<offheap unit="MB">500</offheap>
<disk unit="GB" persistent="true">3</disk>
</resources>
</cache-template>
<cache alias="proc_req_cache" uses-template="PROC_REQTemplate"/>
</config>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.