Package org.infinispan

Examples of org.infinispan.Cache.replace()


      c.evict("k2");
      assert l.passivated.isEmpty();
      assert l.loaded.size() == 1;
      assert l.activated.isEmpty();

      c.replace("k2", "something");
      assert l.passivated.isEmpty();
      assert l.loaded.size() == 2;
      assert l.loaded.contains("k2");
      assert l.activated.isEmpty();
   }
View Full Code Here


      c.evict("k2");
      assert l.passivated.isEmpty();
      assert l.loaded.size() == 1;
      assert l.activated.isEmpty();

      c.replace("k2", "something");
      assert l.passivated.isEmpty();
      assert l.loaded.size() == 2;
      assert l.loaded.contains("k2");
      assert l.activated.isEmpty();
   }
View Full Code Here

      assert "v".equals(c.get("k"));
      assert "v".equals(c.get("k"));
      Transaction reader = threadLocal.get().tm.suspend();

      threadLocal.get().tm.begin();
      c.replace("k", "v2");
      Transaction writer = threadLocal.get().tm.suspend();

      threadLocal.get().tm.resume(reader);
      assert "v".equals(c.get("k")) : "Should not read uncommitted data";
      reader = threadLocal.get().tm.suspend();
View Full Code Here

      c.evict("k2");
      assert l.passivated.isEmpty();
      assert l.loaded.size() == 1;
      assert l.activated.isEmpty();

      c.replace("k2", "something");
      assert l.passivated.isEmpty();
      assert l.loaded.size() == 2;
      assert l.loaded.contains("k2");
      assert l.activated.isEmpty();
   }
View Full Code Here

      assert "v".equals(c.get("k"));
      assert "v".equals(c.get("k"));
      Transaction reader = threadLocal.get().tm.suspend();

      threadLocal.get().tm.begin();
      c.replace("k", "v2");
      Transaction writer = threadLocal.get().tm.suspend();

      threadLocal.get().tm.resume(reader);
      assert "v".equals(c.get("k")) : "Should not read uncommitted data";
      reader = threadLocal.get().tm.suspend();
View Full Code Here

   public void testLifespanExpiryInReplace() throws InterruptedException {
      Cache cache = cm.getCache();
      long lifespan = 10000;
      assert cache.get("k") == null;
      assert cache.replace("k", "v", lifespan, MILLISECONDS) == null;
      assert cache.get("k") == null;
      cache.put("k", "v-old");
      assert cache.get("k").equals("v-old");
      long startTime = System.currentTimeMillis();
      assert cache.replace("k", "v", lifespan, MILLISECONDS) != null;
View Full Code Here

      assert cache.replace("k", "v", lifespan, MILLISECONDS) == null;
      assert cache.get("k") == null;
      cache.put("k", "v-old");
      assert cache.get("k").equals("v-old");
      long startTime = System.currentTimeMillis();
      assert cache.replace("k", "v", lifespan, MILLISECONDS) != null;
      assert cache.get("k").equals("v");
      while (System.currentTimeMillis() < startTime + lifespan) {
         assert cache.get("k").equals("v");
         Thread.sleep(50);
      }
View Full Code Here

      assert cache.get("k") == null;


      startTime = System.currentTimeMillis();
      cache.put("k", "v");
      assert cache.replace("k", "v", "v2", lifespan, MILLISECONDS);
      while (System.currentTimeMillis() < startTime + lifespan) {
         assert cache.get("k").equals("v2");
         Thread.sleep(50);
      }
View Full Code Here

   public void testIdleExpiryInReplace() throws InterruptedException {
      Cache cache = cm.getCache();
      long idleTime = 10000;
      assert cache.get("k") == null;
      assert cache.replace("k", "v", -1, MILLISECONDS, idleTime, MILLISECONDS) == null;
      assert cache.get("k") == null;
      cache.put("k", "v-old");
      assert cache.get("k").equals("v-old");
      assert cache.replace("k", "v", -1, MILLISECONDS, idleTime, MILLISECONDS) != null;
      assertEquals(cache.get("k"), "v");
View Full Code Here

      assert cache.get("k") == null;
      assert cache.replace("k", "v", -1, MILLISECONDS, idleTime, MILLISECONDS) == null;
      assert cache.get("k") == null;
      cache.put("k", "v-old");
      assert cache.get("k").equals("v-old");
      assert cache.replace("k", "v", -1, MILLISECONDS, idleTime, MILLISECONDS) != null;
      assertEquals(cache.get("k"), "v");

      Thread.sleep(idleTime + 100);
      assert cache.get("k") == null;
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.