Infinispan equivalent to ehcache's copyOnRead and copyOnWrite

Posted by waxwing on Stack Overflow See other posts from Stack Overflow or by waxwing
Published on 2010-05-25T14:29:03Z Indexed on 2010/05/25 14:31 UTC
Read the original article Hit count: 370

Filed under:
|
|
|

Hi,

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));
}

© Stack Overflow or respective owner

Related posts about java

Related posts about cache