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 consolidatePersistenceSettings(CacheManager manager) { if (persistenceConfiguration == null) { if (diskPersistent == Boolean.TRUE) { persistenceConfiguration = new PersistenceConfiguration().strategy(Strategy.LOCALTEMPSWAP); switch (persistenceConfiguration.getStrategy()) { case DISTRIBUTED: case NONE: if (persistenceConfiguration != null && persistenceConfiguration.getSynchronousWrites()) { switch (persistenceConfiguration.getStrategy()) { case NONE: case LOCALTEMPSWAP:
/** * Builder method to set the persistence write mode * * @param synchronousWrites the persistence write mode * @return this PersistenceConfiguration object */ public PersistenceConfiguration synchronousWrites(boolean synchronousWrites) { setSynchronousWrites(synchronousWrites); return this; }
json.put("time To Live Seconds", config.getTimeToLiveSeconds()); if (config.getPersistenceConfiguration() != null) { json.put("Persistence Configuration Strategy", config.getPersistenceConfiguration().getStrategy()); json.put("Persistence Configuration Synchronous writes", config.getPersistenceConfiguration().getSynchronousWrites()); } else { json.put("Persistence Configuration Strategy", "NONE");
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(); }
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); }
/** * {@inheritDoc} */ @Override public String getPersistenceStrategy() { PersistenceConfiguration pc = cache.getCacheConfiguration().getPersistenceConfiguration(); return pc != null ? pc.getStrategy().name() : ""; }
/** * Sets the persistence strategy * * @param strategy the persistence strategy */ public void setStrategy(String strategy) { if (strategy == null) { throw new IllegalArgumentException("strategy must be non-null"); } strategy(Strategy.valueOf(strategy.toUpperCase())); }
/** * Builder method to set the persistence strategy using a String object * * @param strategy the persistence strategy * @return this PersistenceConfiguration object */ public PersistenceConfiguration strategy(String strategy) { setStrategy(strategy); return this; }
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)));
/** * Returns a {@link String} representation of {@link Cache}. */ @Override public String toString() { StringBuilder dump = new StringBuilder(); dump.append("[") .append(" name = ").append(configuration.getName()) .append(" status = ").append(cacheStatus.getStatus()) .append(" eternal = ").append(configuration.isEternal()) .append(" overflowToDisk = ").append(configuration.isOverflowToDisk()) .append(" maxEntriesLocalHeap = ").append(configuration.getMaxEntriesLocalHeap()) .append(" maxEntriesLocalDisk = ").append(configuration.getMaxEntriesLocalDisk()) .append(" memoryStoreEvictionPolicy = ").append(configuration.getMemoryStoreEvictionPolicy()) .append(" timeToLiveSeconds = ").append(configuration.getTimeToLiveSeconds()) .append(" timeToIdleSeconds = ").append(configuration.getTimeToIdleSeconds()) .append(" persistence = ").append(configuration.getPersistenceConfiguration() == null ? "none" : configuration.getPersistenceConfiguration().getStrategy()) .append(" diskExpiryThreadIntervalSeconds = ").append(configuration.getDiskExpiryThreadIntervalSeconds()) .append(registeredEventListeners) .append(" maxBytesLocalHeap = ").append(configuration.getMaxBytesLocalHeap()) .append(" overflowToOffHeap = ").append(configuration.isOverflowToOffHeap()) .append(" maxBytesLocalOffHeap = ").append(configuration.getMaxBytesLocalOffHeap()) .append(" maxBytesLocalDisk = ").append(configuration.getMaxBytesLocalDisk()) .append(" pinned = ") .append(configuration.getPinningConfiguration() != null ? configuration.getPinningConfiguration().getStore().name() : "false") .append(" ]"); return dump.toString(); }
/** * Sets the persistence strategy * * @param strategy the persistence strategy */ public void setStrategy(String strategy) { if (strategy == null) { throw new IllegalArgumentException("strategy must be non-null"); } strategy(Strategy.valueOf(strategy.toUpperCase())); }
private void init() { if (persistenceConfiguration == null) { return; } addAttribute(new SimpleNodeAttribute("strategy", persistenceConfiguration.getStrategy())); addAttribute(new SimpleNodeAttribute("synchronousWrites", persistenceConfiguration.getSynchronousWrites()).optional(true) .defaultValue(PersistenceConfiguration.DEFAULT_SYNCHRONOUS_WRITES)); }
/** * Builder method to set the persistence strategy using a String object * * @param strategy the persistence strategy * @return this PersistenceConfiguration object */ public PersistenceConfiguration strategy(String strategy) { setStrategy(strategy); return this; }
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); }
private void consolidatePersistenceSettings(CacheManager manager) { if (persistenceConfiguration == null) { if (diskPersistent == Boolean.TRUE) { persistenceConfiguration = new PersistenceConfiguration().strategy(Strategy.LOCALTEMPSWAP); switch (persistenceConfiguration.getStrategy()) { case DISTRIBUTED: case NONE: if (persistenceConfiguration != null && persistenceConfiguration.getSynchronousWrites()) { switch (persistenceConfiguration.getStrategy()) { case NONE: case LOCALTEMPSWAP:
.diskExpiryThreadIntervalSeconds(0) .persistence(new PersistenceConfiguration().strategy(Strategy.LOCALRESTARTABLE))); mgr.addCache(testCache);
if (persistenceConfiguration != null && persistenceConfiguration.getStrategy() == null) { errors.add(new CacheConfigError("Persistence configuration found with no strategy set.", getName()));
/** * Sets the persistence strategy * * @param strategy the persistence strategy */ public void setStrategy(String strategy) { if (strategy == null) { throw new IllegalArgumentException("strategy must be non-null"); } strategy(Strategy.valueOf(strategy.toUpperCase())); }
private void init() { if (persistenceConfiguration == null) { return; } addAttribute(new SimpleNodeAttribute("strategy", persistenceConfiguration.getStrategy())); addAttribute(new SimpleNodeAttribute("synchronousWrites", persistenceConfiguration.getSynchronousWrites()).optional(true) .defaultValue(PersistenceConfiguration.DEFAULT_SYNCHRONOUS_WRITES)); }