Examples of LRUExoCache


Examples of org.exoplatform.services.cache.impl.jboss.lru.LRUExoCacheCreator.LRUExoCache

      testPolicy("test-lru-with-old-config");
   }

   private void testPolicy(String cacheName) throws Exception
   {
      LRUExoCache cache = (LRUExoCache)service_.getCacheInstance(cacheName);
      cache.put("a", "a");
      cache.put("b", "a");
      cache.put("c", "a");
      cache.put("d", "a");
      assertEquals(4, cache.getCacheSize());
      cache.put("e", "a");
      assertEquals(5, cache.getCacheSize());
      cache.put("f", "a");
      assertEquals(6, cache.getCacheSize());
      Thread.sleep(1000);
      assertFalse(cache.get("b") == null);
      assertFalse(cache.get("c") == null);
      assertFalse(cache.get("d") == null);
      Thread.sleep(600);
      assertEquals(3, cache.getCacheSize());
      Thread.sleep(500);
      assertEquals(0, cache.getCacheSize());
      cache.setMaxSize(3);
      cache.setTimeToLive(500);
      cache.setMaxAge(1000);
      cache.put("a", "a");
      cache.put("b", "a");
      cache.put("c", "a");
      cache.put("d", "a");
      assertEquals(4, cache.getCacheSize());
      cache.put("e", "a");
      assertEquals(5, cache.getCacheSize());
      cache.put("f", "a");
      Thread.sleep(500);
      cache.get("a");
      cache.get("b");
      assertEquals(3, cache.getCacheSize());
      Thread.sleep(600);
      assertEquals(0, cache.getCacheSize());
   }
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.