Search in sources :

Example 1 with TerracottaConfiguration

use of net.sf.ehcache.config.TerracottaConfiguration in project ff4j by ff4j.

the class FeatureStoreTerracottaTestIT method initStore.

/**
 * {@inheritDoc}
 */
@Override
protected FeatureStore initStore() {
    // Configuration to wirk with Terracotta
    Configuration managerConfiguration = new Configuration();
    managerConfiguration.name("config").terracotta(new TerracottaClientConfiguration().url(TERRACOTTA_URL)).defaultCache(new CacheConfiguration().maxBytesLocalHeap(128, MemoryUnit.MEGABYTES).terracotta(new TerracottaConfiguration())).cache(new CacheConfiguration().name(FF4jEhCacheWrapper.CACHENAME_FEATURES).maxBytesLocalHeap(128, MemoryUnit.MEGABYTES).terracotta(new TerracottaConfiguration()));
    FeatureStoreEhCache ehcacheStore = new FeatureStoreEhCache(managerConfiguration);
    ehcacheStore.importFeaturesFromXmlFile("ff4j.xml");
    return ehcacheStore;
}
Also used : TerracottaClientConfiguration(net.sf.ehcache.config.TerracottaClientConfiguration) CacheConfiguration(net.sf.ehcache.config.CacheConfiguration) TerracottaConfiguration(net.sf.ehcache.config.TerracottaConfiguration) Configuration(net.sf.ehcache.config.Configuration) TerracottaClientConfiguration(net.sf.ehcache.config.TerracottaClientConfiguration) TerracottaConfiguration(net.sf.ehcache.config.TerracottaConfiguration) FeatureStoreEhCache(org.ff4j.store.FeatureStoreEhCache) CacheConfiguration(net.sf.ehcache.config.CacheConfiguration)

Example 2 with TerracottaConfiguration

use of net.sf.ehcache.config.TerracottaConfiguration in project onebusaway-application-modules by camsys.

the class EhCacheFactoryBean method createCache.

/**
 * Create a raw Cache object based on the configuration of this FactoryBean.
 */
private Cache createCache() {
    CacheConfiguration config = new CacheConfiguration(this.cacheName, this.maxElementsInMemory);
    config.setMemoryStoreEvictionPolicyFromObject(this.memoryStoreEvictionPolicy);
    config.setEternal(this.eternal);
    config.setTimeToLiveSeconds(this.timeToLive);
    config.setTimeToIdleSeconds(this.timeToIdle);
    PersistenceConfiguration pc = new PersistenceConfiguration();
    if (this.diskPersistent)
        pc.strategy(PersistenceConfiguration.Strategy.LOCALRESTARTABLE);
    else if (this.overflowToDisk)
        pc.strategy(PersistenceConfiguration.Strategy.LOCALTEMPSWAP);
    else
        pc.strategy(PersistenceConfiguration.Strategy.NONE);
    config.setDiskExpiryThreadIntervalSeconds(this.diskExpiryThreadIntervalSeconds);
    config.setMaxElementsOnDisk(this.maxElementsOnDisk);
    if (this.terracottaClustered) {
        TerracottaConfiguration tcConfig = new TerracottaConfiguration();
        tcConfig.setClustered(true);
        config.terracotta(tcConfig);
    }
    return new Cache(config);
}
Also used : PersistenceConfiguration(net.sf.ehcache.config.PersistenceConfiguration) TerracottaConfiguration(net.sf.ehcache.config.TerracottaConfiguration) CacheConfiguration(net.sf.ehcache.config.CacheConfiguration) SelfPopulatingCache(net.sf.ehcache.constructs.blocking.SelfPopulatingCache) BlockingCache(net.sf.ehcache.constructs.blocking.BlockingCache) UpdatingSelfPopulatingCache(net.sf.ehcache.constructs.blocking.UpdatingSelfPopulatingCache) Cache(net.sf.ehcache.Cache)

Aggregations

CacheConfiguration (net.sf.ehcache.config.CacheConfiguration)2 TerracottaConfiguration (net.sf.ehcache.config.TerracottaConfiguration)2 Cache (net.sf.ehcache.Cache)1 Configuration (net.sf.ehcache.config.Configuration)1 PersistenceConfiguration (net.sf.ehcache.config.PersistenceConfiguration)1 TerracottaClientConfiguration (net.sf.ehcache.config.TerracottaClientConfiguration)1 BlockingCache (net.sf.ehcache.constructs.blocking.BlockingCache)1 SelfPopulatingCache (net.sf.ehcache.constructs.blocking.SelfPopulatingCache)1 UpdatingSelfPopulatingCache (net.sf.ehcache.constructs.blocking.UpdatingSelfPopulatingCache)1 FeatureStoreEhCache (org.ff4j.store.FeatureStoreEhCache)1