I seem to having a similar problem getting the ehcache to work properly. The cache seems to be being hit, i.e. there are debug statements indicating the validity/existence of one of the objects I want to cache (RulebaseInstance), e.g.
Code:
[DEBUG] (Cache.java:878) - softlaw.hmrc.esi.data.model.RulebaseInstance#1 now: 1133296516481
[DEBUG] (Cache.java:879) - softlaw.hmrc.esi.data.model.RulebaseInstance#1 Creation Time: 1133296478003 Next To Last Access Time: 1133296516331
[DEBUG] (Cache.java:881) - softlaw.hmrc.esi.data.model.RulebaseInstance#1 mostRecentTime: 1133296516331
[DEBUG] (Cache.java:882) - softlaw.hmrc.esi.data.model.RulebaseInstance#1 Age to Idle: 120000 Age Idled: 150
[DEBUG] (Cache.java:906) - softlaw.hmrc.esi.data.model.RulebaseInstance: Is element with key softlaw.hmrc.esi.data.model.RulebaseInstance#1 expired?: false
and when I look at the statistics for the 2nd level cache, it correctly shows the values it cached from the initial hit/put:
Code:
[ INFO] (RBSessionServiceImpl.java:161) - key:1-->{_subclass=softlaw.hmrc.esi.data.model.RulebaseInstance, _lazyPropertiesUnfetched=true, data=[B@19bd8b4, auditData=[Ljava.lang.Object;@b04589, name=ESI-RB, liveDate=2005-11-11 12:37:27.0, version=1}
but monitoring the database traffic with p6spy shows that a select statement is still being issued every time the application reads that particular object. This observation is backed up by Oracle's STATSPACK and the fact that the application is slow as a dog.
This behaviour occurs on Weblogic 8.1SP4, Resin 3.0.14 and Tomcat 4.1.31.
My question: How can I seemlingly get cache hits for an obejct but still generate database traffic?