I'm trying to setup a Spring-MVC 4.2 xml-configured project to use JCache using xml-configured ehcache 3.5 implementation.
How can I use @Cacheable
from Spring or @CacheResult
from JCache to call a method that doesn't have any parameters and returns one object? The Object is of type List<String>
. How do I add the generic as a value type in ehcache.xml?
Also in general, what is the proper way of configuring the setup I described above? I started with ehcache.xml but I still have nothing in Spring configuration xml file to connect the project to it.
Here's some of what I have so far in ehcache.xml:
<config
xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
xmlns:eh='http://www.ehcache.org/v3'
xmlns:jsr107='http://www.ehcache.org/v3/jsr107'
xsi:schemaLocation="http://www.ehcache.org/v3
http://www.ehcache.org/schema/ehcache-core-3.3.xsd
http://www.ehcache.org/v3/jsr107
http://www.ehcache.org/schema/ehcache-107-ext-3.3.xsd">
<cache-template name="template">
<expiry><ttl unit="minutes">2</ttl></expiry>
<heap>1</heap>
<key-type>java.lang.Integer</key-type>
</cache-template>
<cache name="cache1" uses-template="template">
<value-type>java.util.List</value-type>
</cache>
</config>
I understand that each <config>
represents a CacheManager. How can I wire this in Spring's xml?