@Configuration @EnableCaching public class CachingConfig implements CachingConfigurer { @Bean(destroyMethod="shutdown") public net.sf.ehcache.CacheManager ehCacheManager() { CacheConfiguration cacheConfiguration = new CacheConfiguration(); cacheConfiguration.setName("myCacheName"); cacheConfiguration.setMemoryStoreEvictionPolicy("LRU"); cacheConfiguration.setMaxEntriesLocalHeap(1000); net.sf.ehcache.config.Configuration config = new net.sf.ehcache.config.Configuration(); config.addCache(cacheConfiguration); return net.sf.ehcache.CacheManager.newInstance(config); } @Bean @Override public CacheManager cacheManager() { return new EhCacheCacheManager(ehCacheManager()); } @Bean @Override public KeyGenerator keyGenerator() { return new SimpleKeyGenerator(); } }
/** * Maximum number of entries that may be stored in local heap memory store. */ public void setMaxEntriesLocalHeap(long maxEntries) { cacheConfiguration.setMaxEntriesLocalHeap(maxEntries); }
/** * Builder that sets the maximum objects to be held in memory (0 = no limit). * <p> * This property can be modified dynamically while the cache is operating. * * @param maxElementsInMemory The maximum number of elements in memory, before they are evicted (0 == no limit) * @return this configuration instance */ public final CacheConfiguration maxEntriesLocalHeap(int maxElementsInMemory) { setMaxEntriesLocalHeap(maxElementsInMemory); return this; }
/** * Sets the maximum objects to be held in memory (0 = no limit). * <p> * This property can be modified dynamically while the cache is operating. * * @param maxElementsInMemory The maximum number of elements in memory, before they are evicted (0 == no limit) * @deprecated use {@link #setMaxEntriesLocalHeap(long)} */ @Deprecated public final void setMaxElementsInMemory(int maxElementsInMemory) { setMaxEntriesLocalHeap(maxElementsInMemory); }
/** * {@inheritDoc} */ @Override public void setMaxEntriesLocalHeap(long maxEntries) { if (getMaxEntriesLocalHeap() != maxEntries) { try { cache.getCacheConfiguration().setMaxEntriesLocalHeap(maxEntries); } catch (RuntimeException e) { throw Utils.newPlainException(e); } } }
/** * Builder that sets the maximum objects to be held in memory (0 = no limit). * <p> * This property can be modified dynamically while the cache is operating. * * @param maxElementsInMemory The maximum number of elements in memory, before they are evicted (0 == no limit) * @return this configuration instance */ public final CacheConfiguration maxEntriesLocalHeap(int maxElementsInMemory) { setMaxEntriesLocalHeap(maxElementsInMemory); return this; }
/** * Maximum number of entries that may be stored in local heap memory store. */ public void setMaxEntriesLocalHeap(long maxEntries) { cacheConfiguration.setMaxEntriesLocalHeap(maxEntries); }
/** * Builder that sets the maximum objects to be held in memory (0 = no limit). * <p/> * This property can be modified dynamically while the cache is operating. * * @param maxElementsInMemory The maximum number of elements in memory, before they are evicted (0 == no limit) * @return this configuration instance */ public final CacheConfiguration maxEntriesLocalHeap(int maxElementsInMemory) { setMaxEntriesLocalHeap(maxElementsInMemory); return this; }
/** * Builder that sets the maximum objects to be held in memory (0 = no limit). * <p/> * This property can be modified dynamically while the cache is operating. * * @param maxElementsInMemory The maximum number of elements in memory, before they are evicted (0 == no limit) * @return this configuration instance */ public final CacheConfiguration maxEntriesLocalHeap(int maxElementsInMemory) { setMaxEntriesLocalHeap(maxElementsInMemory); return this; }
/** * Maximum number of entries that may be stored in local heap memory store. */ public void setMaxEntriesLocalHeap(long maxEntries) { cacheConfiguration.setMaxEntriesLocalHeap(maxEntries); }
/** * Maximum number of entries that may be stored in local heap memory store. */ public void setMaxEntriesLocalHeap(long maxEntries) { cacheConfiguration.setMaxEntriesLocalHeap(maxEntries); }
/** * Sets the maximum objects to be held in memory (0 = no limit). * <p> * This property can be modified dynamically while the cache is operating. * * @param maxElementsInMemory The maximum number of elements in memory, before they are evicted (0 == no limit) * @deprecated use {@link #setMaxEntriesLocalHeap(long)} */ @Deprecated public final void setMaxElementsInMemory(int maxElementsInMemory) { setMaxEntriesLocalHeap(maxElementsInMemory); }
/** * Sets the maximum objects to be held in memory (0 = no limit). * <p/> * This property can be modified dynamically while the cache is operating. * * @param maxElementsInMemory The maximum number of elements in memory, before they are evicted (0 == no limit) * @deprecated use {@link #setMaxEntriesLocalHeap(long)} */ @Deprecated public final void setMaxElementsInMemory(int maxElementsInMemory) { setMaxEntriesLocalHeap(maxElementsInMemory); }
/** * Sets the maximum objects to be held in memory (0 = no limit). * <p/> * This property can be modified dynamically while the cache is operating. * * @param maxElementsInMemory The maximum number of elements in memory, before they are evicted (0 == no limit) * @deprecated use {@link #setMaxEntriesLocalHeap(long)} */ @Deprecated public final void setMaxElementsInMemory(int maxElementsInMemory) { setMaxEntriesLocalHeap(maxElementsInMemory); }
@Override public final boolean updateMaxEntries(int newValue) { delegate.getCacheConfiguration().setMaxEntriesLocalHeap(newValue); return true; }
/** * Sets the maximum objects to be held in memory (0 = no limit). * * @param maxElementsInMemory The maximum number of elements in memory, before they are evicted (0 == no limit) */ public void setMaxEntriesLocalHeap(long maxEntriesLocalHeap) { cache.getCacheConfiguration().setMaxEntriesLocalHeap(maxEntriesLocalHeap); }
/** * Sets the maximum objects to be held in memory (0 = no limit). * * @param maxEntriesLocalHeap The maximum number of elements in memory, before they are evicted (0 * == no limit) */ public void setMaxEntriesLocalHeap(long maxEntriesLocalHeap) { cache.getCacheConfiguration().setMaxEntriesLocalHeap(maxEntriesLocalHeap); }
/** * {@inheritDoc} */ public void setMaxEntriesLocalHeap(long maxEntries) { if (getMaxEntriesLocalHeap() != maxEntries) { try { cache.getCacheConfiguration().setMaxEntriesLocalHeap(maxEntries); } catch (RuntimeException e) { throw Utils.newPlainException(e); } } }
public void setMaxElementsInMemory( int maxElementsInMemory ) { this.maxElementsInMemory = maxElementsInMemory; if ( this.ehcache != null ) { this.ehcache.getCacheConfiguration().setMaxElementsInMemory( this.maxElementsInMemory ); this.ehcache.getCacheConfiguration().setMaxEntriesLocalHeap( this.maxElementsInMemory ); } }
@Bean(destroyMethod = "shutdown") public net.sf.ehcache.CacheManager ehCacheManager() { CacheConfiguration cacheConfiguration = new CacheConfiguration(); cacheConfiguration.setName("restApiAuthTokenCache"); cacheConfiguration.setMemoryStoreEvictionPolicy("LRU"); cacheConfiguration.setMaxEntriesLocalHeap(0); // 0 = MAX cacheConfiguration.setTimeToLiveSeconds(14400); // 4 hours. cacheConfiguration.setEternal(false); net.sf.ehcache.config.Configuration config = new net.sf.ehcache.config.Configuration(); config.addCache(cacheConfiguration); return net.sf.ehcache.CacheManager.newInstance(config); }