Speak now
Please Wait Image Converting Into Text...
Embark on a journey of knowledge! Take the quiz and earn valuable credits.
Challenge yourself and boost your learning! Start the quiz now to earn credits.
Unlock your potential! Begin the quiz, answer questions, and accumulate credits along the way.
General Tech Bugs & Fixes . 1 year ago
Turn Your Knowledge into Earnings.
I want to cache a few of my dao queries. And it works, but cache doesn't expire. What I'm doing wrong?
My ehcache.xml:
xmlns='http://www.ehcache.org/v3' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jsr107="http://www.ehcache.org/v3/jsr107" xsi:schemaLocation="http://www.ehcache.org/v3 http://www.ehcache.org/schema/ehcache-core-3.0.xsd http://www.ehcache.org/v3/jsr107 http://www.ehcache.org/schema/ehcache-107-ext-3.0.xsd"> <cache alias="test"> java.lang.String xxx.model.SignalValueType unit="seconds">5 unit="entries">100 unit="MB">10 cache>
In application.properties I have entry:
spring.cache.jcache.config=classpath:ehcache.xml
In pom:
javax.cache cache-api runtime org.ehcache ehcache
And my query:
@Cacheable(value = "test", key = "#code") @Override public SignalValueType getSignalValueType(String code) { SignalValueType signalType = (SignalValueType) sf.getCurrentSession() .createQuery("FROM SignalValueType svt WHERE svt.code = :code").setParameter("code", code) .uniqueResult(); return signalType; }
I expect 5 seconds expiring, but after this time (and longer) query is still cached. What I'm doing wrong?
General Tech 9 Answers
General Tech 7 Answers
General Tech 3 Answers
General Tech 2 Answers
Banking, Finance & Insurance
Mobile Technologies
Career Talk
General Tech
Commerce & Accounting
Career Talk0 Answers
General Tech0 Answers
Digital Marketing0 Answers
Internet of Things0 Answers
Interview Questions0 Answers
Your experience on this site will be improved by allowing cookies.