public GoCacheFactory(TransactionSynchronizationManager transactionSynchronizationManager, @Value("${cruise.cache.elements.limit}") int maxElementsInMemory, @Value("${cruise.cache.is.eternal}") boolean eternal) { this.transactionSynchronizationManager = transactionSynchronizationManager; cacheConfiguration = new CacheConfiguration("goCache", maxElementsInMemory) .persistence(new PersistenceConfiguration().strategy(PersistenceConfiguration.Strategy.NONE)) .eternal(eternal) .memoryStoreEvictionPolicy(MemoryStoreEvictionPolicy.LRU); }
private void persistence(final Config conf) { PersistenceConfiguration persistence = new PersistenceConfiguration(); sstr(path + ".persistence", conf, "strategy", persistence::setStrategy); sbool(path + ".persistence", conf, "synchronousWrites", persistence::setSynchronousWrites); cache.addPersistence(persistence); }
private static CacheConfiguration cacheConfiguration() { return new CacheConfiguration(CACHE_NAME, 2048) .persistence(new PersistenceConfiguration().strategy(PersistenceConfiguration.Strategy.NONE)) .timeToIdleSeconds(120) .timeToLiveSeconds(0) .eternal(false) .memoryStoreEvictionPolicy(MemoryStoreEvictionPolicy.LRU); }
diskExpiryThreadIntervalSeconds(0).// persistence(new PersistenceConfiguration().strategy(PersistenceConfiguration.Strategy.NONE)));
private void consolidatePersistenceSettings(CacheManager manager) { if (persistenceConfiguration == null) { if (diskPersistent == Boolean.TRUE) { persistenceConfiguration = new PersistenceConfiguration().strategy(Strategy.LOCALTEMPSWAP);
supportConfig = supportConfig.persistence(new PersistenceConfiguration().strategy(Strategy.NONE)); int activeSize = 2 * refreshAheadConfig.getBatchSize() * refreshAheadConfig.getNumberOfThreads(); supportConfig = supportConfig.maxEntriesLocalHeap(activeSize); supportConfig = supportConfig.persistence(new PersistenceConfiguration().strategy(Strategy.DISTRIBUTED));
Cache testCache = new Cache(new CacheConfiguration("http", 100000) .memoryStoreEvictionPolicy(MemoryStoreEvictionPolicy.LFU) .eternal(false) .timeToLiveSeconds(60) .timeToIdleSeconds(30) .diskExpiryThreadIntervalSeconds(0) //Persist everything and keep it on restart .persistence(new PersistenceConfiguration().strategy(Strategy.LOCALRESTARTABLE)));
public HstCacheEhCacheImpl(final Ehcache ehcache) { this(ehcache, new PersistenceConfiguration().strategy(PersistenceConfiguration.Strategy.NONE)); }
public CompositeHstCache(final Ehcache ehcache) { this(ehcache, new PersistenceConfiguration().strategy(PersistenceConfiguration.Strategy.NONE)); }
private void persistence(final Config conf) { PersistenceConfiguration persistence = new PersistenceConfiguration(); sstr(path + ".persistence", conf, "strategy", persistence::setStrategy); sbool(path + ".persistence", conf, "synchronousWrites", persistence::setSynchronousWrites); cache.addPersistence(persistence); }
private Cache createCache() { Cache eventsDeliveredCache = new Cache( new CacheConfiguration(this.proxyIdentifier, 0).memoryStoreEvictionPolicy( MemoryStoreEvictionPolicy.LRU) .eternal(true) .persistence( new PersistenceConfiguration().strategy(Strategy.LOCALTEMPSWAP)) .transactionalMode(TransactionalMode.OFF)); eventsDeliveredCache.disableDynamicFeatures(); this.cacheManager = this.getOrCreateCacheManager(super.diskStorePath); this.cacheManager.addCache(eventsDeliveredCache); return this.cacheManager.getCache(this.proxyIdentifier); }
protected HttpCache(String name) { CacheManager manager = CacheManager.getInstance(); this._cache = new Cache( new CacheConfiguration(name, 10000) .memoryStoreEvictionPolicy(MemoryStoreEvictionPolicy.LFU) .eternal(false) .timeToLiveSeconds(3600) .timeToIdleSeconds(1200) .diskExpiryThreadIntervalSeconds(0) .persistence(new PersistenceConfiguration().strategy(Strategy.LOCALTEMPSWAP))); manager.addCache(this._cache); }
private void consolidatePersistenceSettings(CacheManager manager) { if (persistenceConfiguration == null) { if (diskPersistent == Boolean.TRUE) { persistenceConfiguration = new PersistenceConfiguration().strategy(Strategy.LOCALTEMPSWAP);
private void consolidatePersistenceSettings(CacheManager manager) { if (persistenceConfiguration == null) { if (diskPersistent == Boolean.TRUE) { persistenceConfiguration = new PersistenceConfiguration().strategy(Strategy.LOCALTEMPSWAP);
public DefaultCacheManagerProvider() { net.sf.ehcache.config.Configuration config = new net.sf.ehcache.config.Configuration(); config.setUpdateCheck(false); CacheConfiguration tokenCacheConfiguration = new CacheConfiguration(). maxEntriesLocalHeap(DEFAULT_MAX_CACHE_ENTRIES). name("tokenCache"). persistence(new PersistenceConfiguration().strategy(Strategy.NONE)); tokenCacheConfiguration.validateConfiguration(); config.addCache(tokenCacheConfiguration ); cacheManager = CacheManager.create(config); }
private static CacheManager buildCache(CacheConfig config) { CacheManager manager; if (config.getConfigurationPath() != null) { manager = CacheManager.newInstance(config.getConfigurationPath()); } else { Configuration cacheConfig = new Configuration(); cacheConfig.setMaxBytesLocalDisk((long) config.getDiskCacheSize()); cacheConfig.setMaxBytesLocalHeap((long) config.getHeapSize()); CacheConfiguration defaultCacheConfiguration = new CacheConfiguration() .persistence( new PersistenceConfiguration() .strategy( PersistenceConfiguration.Strategy .LOCALTEMPSWAP)); cacheConfig.defaultCache(defaultCacheConfiguration); if (config.isUseDiskCache()) { DiskStoreConfiguration diskConfig = new DiskStoreConfiguration(); diskConfig.setPath(config.getCacheDirectory().toAbsolutePath().toString()); cacheConfig.diskStore(diskConfig); } manager = new CacheManager(cacheConfig); manager.addCache(DEFAULT_CACHE); Cache cache = manager.getCache(DEFAULT_CACHE); SelfPopulatingCache populatingCache = new SelfPopulatingCache(cache, new S3ChunkEntryFactory(config)); manager.replaceCacheWithDecoratedCache(cache, populatingCache); } return manager; }
public LocalCacheManager(String name, int max, int exptime, boolean copyOnRead, boolean copyOnWrite) { this.cache = CacheManager.getInstance().getCache(name); if (cache == null) { CacheConfiguration config = new CacheConfiguration(name, max) .copyOnRead(copyOnRead) .copyOnWrite(copyOnWrite) .memoryStoreEvictionPolicy(MemoryStoreEvictionPolicy.LRU) .eternal(false) .timeToLiveSeconds(exptime) .timeToIdleSeconds(exptime) .diskExpiryThreadIntervalSeconds(60) .persistence(new PersistenceConfiguration().strategy(PersistenceConfiguration.Strategy.NONE)); this.cache = new Cache(config, null, null); CacheManager.getInstance().addCache(cache); if (logger.isInfoEnabled()) { logger.info("Arcus k/v local cache is enabled : %s", cache.toString()); } } }
public NcwmsCatalogue(NcwmsConfig config) throws IOException { super(config, new SimpleLayerNameMapper()); this.styleCatalogue = SldTemplateStyleCatalogue.getStyleCatalogue(); dynamicCacheEnabled = config.getDynamicCacheInfo().isEnabled(); if (dynamicCacheEnabled) { if (EdalCache.cacheManager.cacheExists(CACHE_NAME) == false) { NcwmsDynamicCacheInfo cacheInfo = config.getDynamicCacheInfo(); /* * Configure cache */ CacheConfiguration cacheConfig = new CacheConfiguration(CACHE_NAME, cacheInfo.getNumberOfDatasets()) .memoryStoreEvictionPolicy(EVICTION_POLICY) .persistence(new PersistenceConfiguration() .strategy(PERSISTENCE_STRATEGY)) .transactionalMode(TRANSACTIONAL_MODE); if (cacheInfo.getElementLifetimeMinutes() > 0) { cacheConfig.setTimeToLiveSeconds( (long) (cacheInfo.getElementLifetimeMinutes() * 60)); } else { cacheConfig.eternal(true); } dynamicDatasetCache = new Cache(cacheConfig); EdalCache.cacheManager.addCache(dynamicDatasetCache); } else { dynamicDatasetCache = EdalCache.cacheManager.getCache(CACHE_NAME); } } }
/** * 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); }
private Ehcache buildCache(final TicketDefinition ticketDefinition) { val cache = casProperties.getTicket().getRegistry().getEhcache(); val configExists = ResourceUtils.doesResourceExist(cache.getConfigLocation()); val ehcacheProperties = casProperties.getTicket().getRegistry().getEhcache(); val bean = new EhCacheFactoryBean(); bean.setCacheName(ticketDefinition.getProperties().getStorageName()); LOGGER.debug("Constructing Ehcache cache [{}]", bean.getName()); if (configExists) { bean.setCacheEventListeners(CollectionUtils.wrapSet(ticketRMISynchronousCacheReplicator())); bean.setBootstrapCacheLoader(ticketCacheBootstrapCacheLoader()); } else { LOGGER.warn("In registering ticket definition [{}], Ehcache configuration file [{}] cannot be found " + "so no cache event listeners will be configured to bootstrap. " + "The ticket registry will operate in standalone mode", ticketDefinition.getPrefix(), cache.getConfigLocation()); } bean.setTimeToIdle((int) ticketDefinition.getProperties().getStorageTimeout()); bean.setTimeToLive((int) ticketDefinition.getProperties().getStorageTimeout()); bean.setDiskExpiryThreadIntervalSeconds(ehcacheProperties.getDiskExpiryThreadIntervalSeconds()); bean.setEternal(ehcacheProperties.isEternal()); bean.setMaxEntriesLocalHeap(ehcacheProperties.getMaxElementsInMemory()); bean.setMaxEntriesInCache(ehcacheProperties.getMaxElementsInCache()); bean.setMaxEntriesLocalDisk(ehcacheProperties.getMaxElementsOnDisk()); bean.setMemoryStoreEvictionPolicy(ehcacheProperties.getMemoryStoreEvictionPolicy()); val c = new PersistenceConfiguration(); c.strategy(ehcacheProperties.getPersistence()); c.setSynchronousWrites(ehcacheProperties.isSynchronousWrites()); bean.persistence(c); bean.afterPropertiesSet(); return bean.getObject(); }