Package net.sf.ehcache.config

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


    }
   
    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

    }
   
   
    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

    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

           
            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

    }
   
    public static synchronized CacheManager getCacheManager() {
        if (_cacheManager == null) {
            Configuration config = new Configuration();
            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

        }
        directoryService.setInstanceLayout(instanceLayout);

        // EhCache in disabled-like-mode
        Configuration ehCacheConfig = new Configuration();
        CacheConfiguration defaultCache = new CacheConfiguration("default", 1).eternal(false).timeToIdleSeconds(30)
                .timeToLiveSeconds(30).overflowToDisk(false);
        ehCacheConfig.addDefaultCache(defaultCache);
        CacheService cacheService = new CacheService(new CacheManager(ehCacheConfig));
        directoryService.setCacheService(cacheService);
View Full Code Here

    public static Store create( Ehcache cache, String diskStorePath, Pool<PoolableStore> onHeapPool,
                                Pool<PoolableStore> onDiskPool )
    {

        CacheConfiguration config = cache.getCacheConfiguration();
        MemoryStore memoryStore = createMemoryStore( cache, onHeapPool );
        DirectMemoryStore offHeapStore = createOffHeapStore( cache );
        DiskStore diskStore = null; //need to implement disk backing to store.
        Store store = null;
        if ( diskStore == null )
        {
            store = new FrontEndCacheTier<MemoryStore, DirectMemoryStore>( memoryStore, offHeapStore,
                                                                           config.getCopyStrategy(),
                                                                           new MockSearchManager(),
                                                                           config.isCopyOnWrite(),
                                                                           config.isCopyOnRead() )
            {

                @Override
                public Object getMBean()
                {
View Full Code Here

    @BeforeClass
    public static void setUpGlobal() {
        Configuration config = new Configuration();
        config.addDefaultCache(
                new CacheConfiguration("default", Integer.MAX_VALUE)
                    .memoryStoreEvictionPolicy(MemoryStoreEvictionPolicy.LFU)
                    .overflowToDisk(false));
        CACHE_MANAGER = CacheManager.create(config);
    }
View Full Code Here

            }
           
            cacheManager = EHCacheUtil.createCacheManager(conf);
        }
       
        CacheConfiguration requestCC = EHCacheUtil.getCacheConfiguration(REQUEST_CACHE_KEY, cacheManager);
       
        Ehcache newCache = new Cache(requestCC);
        requestCache = cacheManager.addCacheIfAbsent(newCache);
       
        CacheConfiguration responseCC = EHCacheUtil.getCacheConfiguration(RESPONSE_CACHE_KEY, cacheManager);
       
        newCache = new Cache(responseCC);
        responseCache = cacheManager.addCacheIfAbsent(newCache);
    }
View Full Code Here

TOP

Related Classes of net.sf.ehcache.config.CacheConfiguration

Copyright © 2018 www.massapicom. 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.