I am planning to implement a cache solution into an existing web app. Nothing complicated: basically a concurrent map that supports overflowing to disk and automatic eviction. Clustering the cache could be requirement in the future, but not now.
I like ehcache's copyOnRead and copyOnWrite features, because it means that I don't have to manually clone things before modifying something I take out of the cache. Now I have started to look at Infinispan, but I have not found anything equivalent there. Does it exist?
I.e., the following unit tests should pass:
@Test
public void testCopyOnWrite() {
Date date = new Date(0);
cache.put(0, date);
date.setTime(1000);
date = cache.get(0);
assertEquals(0, date.getTime());
}
@Test
public void testCopyOnRead() {
Date date = new Date(0);
cache.put(0, date);
assertNotSame(cache.get(0), cache.get(0));
}
Infinispan does support copyOnRead/copyOnWrite, albeit the actual format isn't pluggable. The configuration element is lazyDeserialization in Infinispan 4.x and storeAsBinary in Infinispan 5.x. Objects are serialized using the pluggable Marshaller framework, which is used for all forms of marshalling including for RPC calls over a network and storage to disk.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With