0

I'm quite new to Terracotta and I've installed and made it work properly with EHcache for distribute caching, but what I'm getting now is not what I really want. In my application I would like to have several client caches (L1) with ehcache, and "propagate" the invalidation of a removed key from a client to all the other clients. I don't want that my cache will reside also on the terracotta server, so I'd like to simply disable L2 caching, so that my objects don't need to be serializable (the only actions done on cache are PUT and REMOVE). I know this could be done using simply ehcache, but i have no multicasting support in my environment (Amazon EC2) and my clients will be automatically created with autoscaling features, so I cannot know their IPs. So basically, I need a Terracotta Server only to propagate the invalidation request to all the clients. Is there any way to accomplish this? Thanks a lot!

Rohi
  • 385
  • 6
  • 22

1 Answers1

0

When you use EhCache backed by Terracotta and in your cache configuration you specify to use terracotta, e.g.:

<cache name="com.xyz.MyPOJO"
  <terracotta/>
</cache>

then your class must be serializable (since Terracotta will attempt to store it on the cache server instance.

However, in your configuration you can specify not to use Terracotta for some caches, e.g.

<cache name="com.xyz.MyPOJO"
  <terracotta/>
</cache>

<cache name="com.xyz.NotServerStoredPOJO"
</cache>

Then your "NotServerStoredPOJO" from the example above will not be stored on the terracotta cache server...instead it will live only in your local EhCache... but by doing that you will not be able to propagate it to other instances if your EhCache in diff JVMs.

So, perhaps you will need to keep something on the terracotta server (some sort of flags/ids) that will indicate what to invalidate. Then in your application code have a common class/functionality that will check that flag before getting value from the local EhCache...if it finds flag/id to be deleted, then it will delete it from local cache and will not return back anything to the requester.

On on the other hand, your use case kind of defeats the purpose of having central cache server. If you want to coordinate multiple cache instances without central location, you can use JGroups http://www.jgroups.org (instead of Terracotta)...its free of commercial license also. But then you'll need to implement your own mechanism over JGroups of how to invalidate certain entries in your local EhCache instances...

user1697575
  • 2,830
  • 1
  • 24
  • 37