java - Eh Cache expiry time in Spring boot -


i have created spring boot application , implemented ehcache in maven project. xml configuration file ehcache follows :

<ehcache xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:nonamespaceschemalocation="ehcache.xsd"  updatecheck="true" monitoring="autodetect"  dynamicconfig="true">  <diskstore path="java.io.tmpdir" />  <cache name="labcabsourceinfocache"      maxentrieslocalheap="10000"     maxentrieslocaldisk="1000"      eternal="false"      diskspoolbuffersizemb="20"     timetoidleseconds="300" timetoliveseconds="300"     memorystoreevictionpolicy="lfu"      transactionalmode="off">     <persistence strategy="localtempswap" /> </cache> 

i have set expiry time 300 in parameters timetoidleseconds & timetoliveseconds

but doesn't works me. didn't used configuration bean cache implementaion. uses @cacheable annotation method meant used cache.

@cacheable(value="labcabsourceinfocache", key="#labalias.concat(#account)")  public string findlabcabsourceinfo(string labalias, string account) {      try {          //codes return "some string"      } catch (exception e) { } return null;  } 

why not evicted or cleared?

you may need enable processing of caching annotations. can try adding @enablecaching on main class.

from tutorial https://spring.io/guides/gs/caching/

the @enablecaching annotation triggers post processor inspects every spring bean presence of caching annotations on public methods. if such annotation found, proxy automatically created intercept method call , handle caching behavior accordingly.

also can add following code in , analyse thorough jconsole, details of caches created in application.

@bean(initmethod="init") @autowired public managementservice managementservice(cachemanager cachemanager,               mbeanserver mbeanserver) {        return new managementservice(cachemanager, mbeanserver, true, true,true, true); } 

Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -