-
1. Re: Local cache persistence to file-store
rvansa May 9, 2016 6:07 PM (in response to tjurak)1 of 1 people found this helpfulInfinispan does not intercept any method calls on your objects to 'flush' them into cache store, neither in version 6.0.2 or any other.
Storing the object itself (as opposite to storing a copy of it) in local cache is more of a performance optimization (because local caches are meant to be fast). Clustered caches always store copy of the object.
You're not supposed to modify the object after storing in the cache (without explicitly overwriting it), and ideally the object should be immutable to avoid threading issues. So your scenario is not supported by design.
-
2. Re: Local cache persistence to file-store
tjurak May 10, 2016 12:59 PM (in response to rvansa)Thank you for answer!
So if I understand it right: if I recreate the cache to be remote, it will store copy of objects which I'm directly manipulating in Java code and Infinispan will store them to file storage everytime I make a change in the object? Or Is there any API in Infinispan which could help me to achieve behavior of having "all-time" synchronized objects between memory and file storage? I hope that I will be able to write some solution for this.
Tomas
-
3. Re: Local cache persistence to file-store
rvansa May 10, 2016 2:09 PM (in response to tjurak)1 of 1 people found this helpfulSorry, the first question is not very clear:
if I recreate the cache to be remote, it will store copy of objects which I'm directly manipulating in Java code
Yes, after calling cache.put(key, value), Infinispan will make a defensive copy of value, and store that copy. When you do a cache.get(key), you'll get a copy of the internally stored copy.
Infinispan will store them to file storage everytime I make a change in the object
No, Infinispan won't check any changes to your object you do, unless you explicitly call cache.put() - and then it will again create the defensive copy of the modified object.
Or Is there any API in Infinispan which could help me to achieve behavior of having "all-time" synchronized objects between memory and file storage?
Not with pure Infinispan. You might consider Hibernate OGM, with that you can automatically get proxy for that object http://docs.oracle.com/javaee/6/api/javax/persistence/EntityManager.html#merge%28T%29, and all modifications will be persisted on transaction commit (maybe all the time with autocommit). But it might be an overkill for your usecase.
-
4. Re: Local cache persistence to file-store
tjurak May 12, 2016 4:04 AM (in response to rvansa)Thank you for help, I understand it now. I will definitely look on Hibernate OGM - maybe this is the way to go with our use case.