title: Infinispan equivalent to ehcache's copyOnRead and copyOnWrite
body: <p>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.</p>
  
  <p>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 <a href="http://www.jboss.org/infinispan" rel="nofollow noreferrer">Infinispan</a>, but I have not found anything equivalent there. Does it exist?</p>
  
  <p>I.e., the following unit tests should pass:</p>
  
  <pre><code>@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));
  }
  </code></pre>