thatmikewilliams wrote:
I'm assuming you're using ehcache here. When an element is cached it has an associated life span, determined by the ehcache configuration for the class. In your case, the life span of the cached element is shorter than the time between the query runs. The element is found in the cache but deemed too old to be used so a fresh query to the database is run.
Thank you for your reply..
I did use ehcache for second level caching. The point is the time between I run 2 queries is like 2 secs. I don't think it would expire in 2 secs. And it worked on my laptop (I got a hit after the second run) but not on another machine (test environment) with the same configuration after I deployed it. I gave me "Memory cache hit, but element expired".