views:

191

answers:

3

Hi,

I have this strange problem with ehcache 2.0 that I hope someone can help me with. I have set up a cluster of two hosts, A and B. I can see that heartbeats are received at both ends, so I'm pretty sure the networking and multicast stuff is working. The problem is that is I put an element into the cache at host A, I can see in the logs of host B that it receives a remote put. But when I request the same element from host B, it runs off to the data base and performs a query nonetheless. What may be the cause of this? Thankful for any pointers!

A: 

Are you using Hibernate and Ehcache as a second level cache? Or just a cache above the DB?

Taylor Gautier
A: 

Based on your description, you are running ehcache under RMI mode w/ multicast automatic peer discovery. Sounds like Cache Event notification is working too. This is my speculation:

Depending on expiry setting in your config, the element might have expired when you "get" from host B.

In the documentation, http://ehcache.org/documentation/storage_options.html, under Memory Use, Spooling and Expiry Strategy:

When there is a get or a getQuiet on an element, it is checked for expiry. If expired, it is removed and null is returned.

you may take a look at your config file, check the value on eternal, timeToIdleSeconds and timeToLiveSeconds.

<cache name="sampleDistributedCache2"
       maxElementsInMemory="10"
       eternal="false"                         
       timeToIdleSeconds="100"
       timeToLiveSeconds="100"
       overflowToDisk="false"></cache>
Anthony Si
A: 

I'm also facing a similar problem. I'm trying to setup Hibernate Second Level Cache using EhCache with Replication. I see the heartbeats at both ends when I add new entries. But the caching doesn't seem to work. I checked the values for expiry strategy and they are set with eternal flag as false and TTL of 120.

Any pointers?

Aparna Chaudhary