@Override public EhCacheCacheManager getObject() throws Exception { if (this.config.getName() == null) { this.config.setName(this.beanName); } this.config.addSizeOfPolicy(new SizeOfPolicyConfiguration().maxDepth(Integer.MAX_VALUE)); Optional.ofNullable(this.maxBytesLocalDisk).ifPresent(this.config::setMaxBytesLocalDisk); Optional.ofNullable(this.maxBytesLocalHeap).ifPresent(this.config::setMaxBytesLocalHeap); Optional.ofNullable(this.maxBytesLocalOffHeap).ifPresent(this.config::setMaxBytesLocalOffHeap); (this.cacheManager = new EhCacheCacheManager(new CacheManager(this.config))).setTransactionAware(true); return this.cacheManager; }
@Override public EhCacheCacheManager getObject() throws Exception { if (this.config.getName() == null) { this.config.setName(this.beanName); } this.config.addSizeOfPolicy(new SizeOfPolicyConfiguration().maxDepth(Integer.MAX_VALUE)); Optional.ofNullable(this.maxBytesLocalDisk).ifPresent(this.config::setMaxBytesLocalDisk); Optional.ofNullable(this.maxBytesLocalHeap).ifPresent(this.config::setMaxBytesLocalHeap); Optional.ofNullable(this.maxBytesLocalOffHeap).ifPresent(this.config::setMaxBytesLocalOffHeap); return (this.manager = new EhCacheCacheManager(new CacheManager(this.config))); }
@Test public void sizeOfPolicy() { Config config = ConfigFactory.empty() .withValue("sizeOfPolicy.maxDepth", fromAnyRef(100)) .withValue("sizeOfPolicy.maxDepthExceededBehavior", fromAnyRef("abort")); Configuration eh = new ConfigurationBuilder().build(config); SizeOfPolicyConfiguration size = eh.getSizeOfPolicyConfiguration(); assertEquals(100, size.getMaxDepth()); assertEquals(MaxDepthExceededBehavior.ABORT, size.getMaxDepthExceededBehavior()); }
@Test public void sizeOfPolicy() { Config config = ConfigFactory .empty() .withValue("sizeOfPolicy.maxDepth", fromAnyRef(100)) .withValue("sizeOfPolicy.maxDepthExceededBehavior", fromAnyRef("abort")); CacheConfigurationBuilder builder = new CacheConfigurationBuilder("c1"); CacheConfiguration cache = builder.build(config); SizeOfPolicyConfiguration size = cache.getSizeOfPolicyConfiguration(); assertEquals(100, size.getMaxDepth()); assertEquals(MaxDepthExceededBehavior.ABORT, size.getMaxDepthExceededBehavior()); }