Examples of CacheConfiguration


Examples of net.sf.ehcache.config.CacheConfiguration

        if (configFileURL != null) {
            cacheManager = EHCacheManagerHolder.getCacheManager(bus, configFileURL);
        } else {
            cacheManager = EHCacheManagerHolder.getCacheManager(bus, getDefaultConfigFileURL());
        }
        CacheConfiguration cc = EHCacheManagerHolder.getCacheConfiguration(key, cacheManager);
       
        Ehcache newCache = new Cache(cc);
        cache = cacheManager.addCacheIfAbsent(newCache);
    }
View Full Code Here

Examples of net.sf.ehcache.config.CacheConfiguration

    }
   
   
    public static CacheConfiguration getCacheConfiguration(String key,
                                                           CacheManager cacheManager) {
        CacheConfiguration cc = cacheManager.getConfiguration().getCacheConfigurations().get(key);
        if (cc == null && key.contains("-")) {
            cc = cacheManager.getConfiguration().getCacheConfigurations().get(
                    key.substring(0, key.lastIndexOf('-')));
        }
        if (cc == null) {
            cc = cacheManager.getConfiguration().getDefaultCacheConfiguration();
        }
        if (cc == null) {
            cc = new CacheConfiguration();
        } else {
            cc = (CacheConfiguration)cc.clone();
        }
        cc.setName(key);
        return cc;
    }
View Full Code Here

Examples of net.sf.ehcache.config.CacheConfiguration

    }
   
   
    public static CacheConfiguration getCacheConfiguration(String key,
                                                           CacheManager cacheManager) {
        CacheConfiguration cc = cacheManager.getConfiguration().getCacheConfigurations().get(key);
        if (cc == null && key.contains("-")) {
            cc = cacheManager.getConfiguration().getCacheConfigurations().get(
                    key.substring(0, key.lastIndexOf('-')));
        }
        if (cc == null) {
            cc = cacheManager.getConfiguration().getDefaultCacheConfiguration();
        }
        if (cc == null) {
            cc = new CacheConfiguration();
        } else {
            cc = (CacheConfiguration)cc.clone();
        }
        cc.setName(key);
        return cc;
    }
View Full Code Here

Examples of net.sf.ehcache.config.CacheConfiguration

        CacheManager cacheManager =
            EHCacheManagerHolder.getCacheManager("testCache2",
                                                 EHCacheManagerHolder.class.getResource("/test-ehcache2.xml"));
       
        String key = "org.apache.wss4j.TokenStore";
        CacheConfiguration cacheConfig =
            EHCacheManagerHolder.getCacheConfiguration(key, cacheManager);
        assertEquals(3600, cacheConfig.getTimeToIdleSeconds());
       
        key = "org.apache.wss4j.TokenStore-{http://ws.apache.org}wss4j";
        CacheConfiguration cacheConfig2 =
            EHCacheManagerHolder.getCacheConfiguration(key, cacheManager);
        assertEquals(360000, cacheConfig2.getTimeToIdleSeconds());
       
        key = "org.apache.wss4j.TokenStore-{http://ws.apache.org}wss4junknown";
        CacheConfiguration cacheConfig3 =
            EHCacheManagerHolder.getCacheConfiguration(key, cacheManager);
        assertEquals(3600, cacheConfig3.getTimeToIdleSeconds());
       
    }
View Full Code Here

Examples of net.sf.ehcache.config.CacheConfiguration

     
      for (final String cacheName : this.cacheManager.getCacheNames()) {
          final Cache cache = this.cacheManager.getCache(cacheName);
         
          if (null != cache && Status.STATUS_ALIVE.equals(cache.getStatus())) {
              final CacheConfiguration cacheConfiguration = cache.getCacheConfiguration();
              final Statistics statistics = cache.getStatistics();
             
              final CacheStatistics cacheStatistics = new CacheStatistics();
             
              cacheStatistics.hits = statistics.getCacheHits();
              cacheStatistics.misses = statistics.getCacheMisses();
              cacheStatistics.size = statistics.getObjectCount();
              cacheStatistics.maxSize = cacheConfiguration.getMaxElementsInMemory() + cacheConfiguration.getMaxElementsOnDisk();
             
              allCacheStatistics.put(cacheName, cacheStatistics);
          }
      }
     
View Full Code Here

Examples of net.sf.ehcache.config.CacheConfiguration

*/
final class EhcacheMap<K, V> extends AbstractMap<K, V> implements ConcurrentMap<K, V> {
  private final Ehcache map;

  public EhcacheMap(MemoryStoreEvictionPolicy evictionPolicy, CacheBuilder builder) {
    CacheConfiguration config = new CacheConfiguration(DEFAULT_CACHE_NAME, builder.maximumCapacity);
    config.setMemoryStoreEvictionPolicyFromObject(evictionPolicy);
    map = new Cache(config);
    map.initialise();
  }
View Full Code Here

Examples of net.sf.ehcache.config.CacheConfiguration

    }
   
    public EHCacheReplayCache(String key, CacheManager cacheManager) {
        this.cacheManager = cacheManager;
       
        CacheConfiguration cc = EHCacheManagerHolder.getCacheConfiguration(key, cacheManager);

        Ehcache newCache = new Cache(cc);
        cache = cacheManager.addCacheIfAbsent(newCache);

        // Set the TimeToLive value from the CacheConfiguration
        ttl = cc.getTimeToLiveSeconds();
    }
View Full Code Here

Examples of net.sf.ehcache.config.CacheConfiguration

    }
   
   
    public static CacheConfiguration getCacheConfiguration(String key,
                                                           CacheManager cacheManager) {
        CacheConfiguration cc = cacheManager.getConfiguration().getCacheConfigurations().get(key);
        if (cc == null && key.contains("-")) {
            cc = cacheManager.getConfiguration().getCacheConfigurations().get(
                    key.substring(0, key.lastIndexOf('-') - 1));
        }
        if (cc == null) {
            cc = cacheManager.getConfiguration().getDefaultCacheConfiguration();
        }
        if (cc == null) {
            cc = new CacheConfiguration();
        } else {
            cc = (CacheConfiguration)cc.clone();
        }
        cc.setName(key);
        return cc;
    }
View Full Code Here

Examples of net.sf.ehcache.config.CacheConfiguration

    public static net.sf.ehcache.CacheManager newEhcacheManager() {
        //Create a singleton CacheManager using defaults
        CacheManager manager = CacheManager.create();
        //Create a Cache specifying its configuration.
        Cache testCache = new Cache(
                new CacheConfiguration("Author", 7)
                        .memoryStoreEvictionPolicy(MemoryStoreEvictionPolicy.LFU)
                        .eternal(false)
                        .timeToLiveSeconds(60)
                        .timeToIdleSeconds(30)
//                        .diskExpiryThreadIntervalSeconds(0)
View Full Code Here

Examples of net.sf.ehcache.config.CacheConfiguration

           
            DiskStoreConfiguration diskConfig = new DiskStoreConfiguration();
            diskConfig.setPath(getTempDir().getPath());
            config.addDiskStore(diskConfig);
           
            CacheConfiguration defaultConfig = new CacheConfiguration();
            defaultConfig.setMaxElementsInMemory(10000);
            defaultConfig.setEternal(false);
            defaultConfig.setOverflowToDisk(false);
            defaultConfig.setTimeToIdleSeconds(120);
            defaultConfig.setTimeToLiveSeconds(120);
            defaultConfig.setDiskPersistent(false);
            defaultConfig.setDiskExpiryThreadIntervalSeconds(120);
            config.addDefaultCache(defaultConfig);
           
            _cacheManager = new CacheManager(config);
        }
        return _cacheManager;
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.