Load cache at startup and read from it

795 views
Skip to first unread message

Rohithaksha Kalluraya

unread,
Apr 23, 2017, 8:23:31 PM4/23/17
to ehcache-users
1. What version of Ehcache you are currently using;
   I am using Ehcache version: 3.2.1

2. Paste the configuration for the Cache/CacheManager you have an issue with;
   <?xml version="1.0" encoding="UTF-8"?>
    xsi:noNamespaceSchemaLocation="http://www.ehcache.org/ehcache.xsd"
    updateCheck="true" monitoring="autodetect" dynamicConfig="true">
    <defaultCache maxElementsInMemory="10000" eternal="true"
    overflowToDisk="false" maxElementsOnDisk="0" diskPersistent="false"
    diskExpiryThreadIntervalSeconds="0" memoryStoreEvictionPolicy="FIFO" />
    <cache name="MyCache" maxElementsInMemory="10000"
    eternal="false" overflowToDisk="true" maxElementsOnDisk="15000"
    diskPersistent="true" memoryStoreEvictionPolicy="LRU" />
   </ehcache>

3. Add any name and version of other library or framework you use Ehcache with (e.g. Hibernate);
   I am using Spring boot framework.

4. Providing JDK and OS versions maybe useful as well.
   I am developing my application in Java 8 on windows (PRODUCTION will be on RHEL).

Below are my requirements:
1. I would like to load the entire cache at the application startup (data is from a select query on a database table).
2. For client requests, always read data from cache.
3. Read data based on different keys (for example, I have list of addresses cached, I need to fetch address based on Id, zip code, city, etc.).
4. Need to set the cache expiry so that it gets refreshed at a configured interval.
5. Persist data in the disk and read this during the application startup only if database query fails during startup.


Can I achieve above requirements using Ehcache in my spring boot application?

Appreciate any insights.

Thank you!

Rohit

Rohithaksha Kalluraya

unread,
Apr 25, 2017, 8:13:19 AM4/25/17
to ehcache-users
I think I found the answer. I am going with manual cache management as spring annotations does not cover all my use cases. Thanks!
Reply all
Reply to author
Forward
0 new messages