Examples of ExoCache


Examples of org.exoplatform.services.cache.ExoCache

      // Ensure the configuration integrity
      final ExoCacheConfig safeConfig = config.clone();
      // Set the region as name
      safeConfig.setName(region);
      final ExoCache simple = factory_.createCache(safeConfig);

      if (managed != null)
      {
         managed.registerCache(simple);
      }
View Full Code Here

Examples of org.exoplatform.services.cache.ExoCache

      /**
       * {@inheritDoc}
       */
      public ExoCache createCache(ExoCacheConfig config) throws ExoCacheInitException
      {
         final ExoCache simple = createCacheInstance(config);
         simple.setName(config.getName());
         simple.setLabel(config.getLabel());
         simple.setMaxSize(config.getMaxSize());
         simple.setLiveTime(config.getLiveTime());
         //       simple.setReplicated(config.isRepicated());
         //       simple.setDistributed(config.isDistributed());
         //       if (simple.isDistributed()) {
         //         simple.addCacheListener(distrbutedListener_);
         //       }
         simple.setLogEnabled(config.isLogEnabled());
         if (simple.isLogEnabled())
         {
            simple.addCacheListener(loggingListener_);
         }
         return simple;
      }
View Full Code Here

Examples of org.exoplatform.services.cache.ExoCache

      // Ensure the configuration integrity
      final ExoCacheConfig safeConfig = config.clone();
      // Set the region as name
      safeConfig.setName(region);
     
      ExoCache simple = null;
      if (factory_ != DEFAULT_FACTORY && safeConfig.getClass().isAssignableFrom(ExoCacheConfig.class) //NOSONAR
         && safeConfig.getImplementation() != null)
      {
         // The implementation exists and the config is not a sub class of ExoCacheConfig
         // we assume that we expect to use the default cache factory
View Full Code Here

Examples of org.exoplatform.services.cache.ExoCache

      /**
       * {@inheritDoc}
       */
      public ExoCache createCache(ExoCacheConfig config) throws ExoCacheInitException
      {
         final ExoCache simple = createCacheInstance(config);
         simple.setName(config.getName());
         simple.setLabel(config.getLabel());
         simple.setMaxSize(config.getMaxSize());
         simple.setLiveTime(config.getLiveTime());
         //       simple.setReplicated(config.isRepicated());
         //       simple.setDistributed(config.isDistributed());
         //       if (simple.isDistributed()) {
         //         simple.addCacheListener(distrbutedListener_);
         //       }
         simple.setLogEnabled(config.isLogEnabled());
         if (simple.isLogEnabled())
         {
            simple.addCacheListener(loggingListener_);
         }
         return simple;
      }
View Full Code Here

Examples of org.exoplatform.services.cache.ExoCache

      service_ = (CacheService)PortalContainer.getInstance().getComponentInstanceOfType(CacheService.class);
   }

   public void testCacheFactory()
   {
      ExoCache cache = service_.getCacheInstance("myCache");
      assertTrue("expect an instance of AbstractExoCache", cache instanceof AbstractExoCache);
      AbstractExoCache aCache = (AbstractExoCache)cache;
      assertTrue("expect a local cache",
         aCache.cache.getCacheConfiguration().clustering().cacheMode() == CacheMode.LOCAL);
      aCache.cache.stop();
View Full Code Here

Examples of org.exoplatform.services.cache.ExoCache

      aCache.cache.stop();
   }

   public void testExoCacheCreator()
   {
      ExoCache cache = service_.getCacheInstance("test-default-impl");
      assertTrue("expect an instance of AbstractExoCache", cache instanceof AbstractExoCache);
      AbstractExoCache aCache = (AbstractExoCache)cache;
      aCache.cache.stop();
      cache = service_.getCacheInstance("test-custom-impl-with-old-config");
      assertTrue("expect an instance of TestExoCache", cache instanceof TestExoCache);
View Full Code Here

Examples of org.exoplatform.services.cache.ExoCache

      assertTrue("expect an instance of TestExoCache", cache instanceof TestExoCache);
   }

   public void testSameCacheManager()
   {
      ExoCache cache1 = service_.getCacheInstance("myCustomCache");
      assertTrue("expect an instance of AbstractExoCache", cache1 instanceof AbstractExoCache);
      AbstractExoCache aCache1 = (AbstractExoCache)cache1;
      CacheContainer cacheContainer1 = aCache1.cache.getCacheManager();

      ExoCache cache2 = service_.getCacheInstance("myCustomCache-Bis");
      assertTrue("expect an instance of AbstractExoCache", cache2 instanceof AbstractExoCache);
      AbstractExoCache aCache2 = (AbstractExoCache)cache2;
      CacheContainer cacheContainer2 = aCache2.cache.getCacheManager();
      assertTrue("The CacheContainer should be the same", cacheContainer1 == cacheContainer2);

      ExoCache cache3 = service_.getCacheInstance("myCustomCache-Bis2");
      assertTrue("expect an instance of AbstractExoCache", cache3 instanceof AbstractExoCache);
      AbstractExoCache aCache3 = (AbstractExoCache)cache3;
      CacheContainer cacheContainer3 = aCache3.cache.getCacheManager();
      assertTrue("The CacheContainer should be the same", cacheContainer1 == cacheContainer3);
View Full Code Here

Examples of org.exoplatform.services.cache.ExoCache

      service_ = (CacheService)PortalContainer.getInstance().getComponentInstanceOfType(CacheService.class);
   }

   public void testCacheFactory()
   {
      ExoCache cache = service_.getCacheInstance("myCache");
      assertTrue("expect an instance of AbstractExoCache", cache instanceof AbstractExoCache);
      AbstractExoCache aCache = (AbstractExoCache)cache;
      assertTrue("expect a local cache", aCache.cache.getConfiguration().getCacheMode() == CacheMode.LOCAL);
      aCache.cache.stop();
      cache = service_.getCacheInstance("cacheDistributed");
View Full Code Here

Examples of org.exoplatform.services.cache.ExoCache

      aCache.cache.stop();
   }

   public void testExoCacheCreator()
   {
      ExoCache cache = service_.getCacheInstance("test-default-impl");
      assertTrue("expect an instance of AbstractExoCache", cache instanceof AbstractExoCache);
      AbstractExoCache aCache = (AbstractExoCache)cache;
      aCache.cache.stop();
      cache = service_.getCacheInstance("test-custom-impl-with-old-config");
      assertTrue("expect an instance of TestExoCache", cache instanceof TestExoCache);
View Full Code Here

Examples of org.exoplatform.services.cache.ExoCache

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

   private void testPolicy(String cacheName) throws Exception
   {
      ExoCache cache = 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(500);
      assertEquals(6, cache.getCacheSize());
      Thread.sleep(600);
      assertEquals(5, cache.getCacheSize());
      cache.setMaxSize(3);
      cache.setLiveTime(1500);
      cache.put("g", "a");
      assertEquals(6, cache.getCacheSize());
      Thread.sleep(1100);
      assertEquals(3, cache.getCacheSize());
      cache.put("h", "a");
      cache.put("i", "a");
      cache.put("j", "a");
      cache.put("k", "a");
      assertEquals(7, cache.getCacheSize());
      Thread.sleep(500);
      assertEquals(4, cache.getCacheSize());
      Thread.sleep(1100);
      assertEquals(3, 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.