-
1. Re: CacheMode.INVALIDATION_SYNC: get notified on new cache entries
andy-l Feb 15, 2017 10:21 AM (in response to andy-l)Seems I have a similar question to this one except I want the invalidation event on add rather than remove. I'm not sure why this isn't supported as my use case seems valid to me. I am using invalidation mode to minimise cross region network traffic, when cache entries change (or are added) I want the cache to load the data from the database as this will be in its local data centre rather than receiving a potentially bloated object.
It sounds like I can use interceptors to get around this so will look for examples on that
-
2. Re: CacheMode.INVALIDATION_SYNC: get notified on new cache entries
william.burns Feb 15, 2017 10:38 AM (in response to andy-l)Add or remove both produce the same logic. All invalidation cache does is send an invalidation message to other nodes when an entry is changed (whether it be a removal, change, or add). The event is then only generated on the local node if an entry was actually invalidated. You can definitely intercept this message using an interceptor as Radim mentioned.
Although I am not sure what you are referring to with the database vs a bloated object. Invalidation cache only sends invalidation messages on write operations containing a key. And if you are using a cache loader this would hit the database for you automatically when an entry is not found locally.
-
3. Re: CacheMode.INVALIDATION_SYNC: get notified on new cache entries
andy-l Feb 15, 2017 11:01 AM (in response to william.burns)For "database vs a bloated object" I meant that if I use a dist/repl cache (instead of invalidation) then I can know about newly added objects but I don't want/need the expense of serialising large objects because I have a locally distributed database to read from instead.
Interceptor seems to work for me but I prefer the simplicity listener events and would be nice if I could just use @CacheEntryCreated
-
4. Re: CacheMode.INVALIDATION_SYNC: get notified on new cache entries
william.burns Feb 15, 2017 11:50 AM (in response to andy-l)Unfortunately this isn't what Invalidation cache was designed for. It is designed when another back end system is the owner of said data and Infinispan allows a cache loader to load directly from this source. Thus data can be thrown out at any point. If data is to change for any reason all nodes just throw out the data. On the next subsequent get the cache loader is then hit to give the updated value to those nodes (so you don't have have to send values between nodes like in your example). If you look at how Invalidation cache works when you do a put it removes the entry from every other node irrespective if the value is the same (further reinforcing the usage of a cache loader). Have you tried using a cache loader that goes to your database in the same data center?
-
5. Re: CacheMode.INVALIDATION_SYNC: get notified on new cache entries
andy-l Feb 15, 2017 11:44 AM (in response to william.burns)ok thanks, I'll take a look at cache loaders. When I looked at them a while back it seemed to be more complicated to configure for a non-jdbc database but I'll take another look
-
6. Re: CacheMode.INVALIDATION_SYNC: get notified on new cache entries
william.burns Feb 15, 2017 11:50 AM (in response to andy-l)What are you using at your "database"?
-
7. Re: CacheMode.INVALIDATION_SYNC: get notified on new cache entries
andy-l Feb 15, 2017 12:16 PM (in response to william.burns)cassandra
-
8. Re: CacheMode.INVALIDATION_SYNC: get notified on new cache entries
william.burns Feb 15, 2017 1:54 PM (in response to andy-l)You should check out to see if you are able to use GitHub - infinispan/infinispan-cachestore-cassandra: Infinispan Cassandra Cache Store . Unfortunately it requires a specific tablespace configuration