本文整理汇总了Java中org.ehcache.config.builders.PooledExecutionServiceConfigurationBuilder类的典型用法代码示例。如果您正苦于以下问题:Java PooledExecutionServiceConfigurationBuilder类的具体用法?Java PooledExecutionServiceConfigurationBuilder怎么用?Java PooledExecutionServiceConfigurationBuilder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PooledExecutionServiceConfigurationBuilder类属于org.ehcache.config.builders包,在下文中一共展示了PooledExecutionServiceConfigurationBuilder类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: EhCacheDao
import org.ehcache.config.builders.PooledExecutionServiceConfigurationBuilder; //导入依赖的package包/类
/**
* To initiate EhCacheDao with cacheManager and cache.
*
* @param cacheName
* name of the cache.
* @param cacheSize
* cache size.
*/
public EhCacheDao(final String cacheName, final long cacheSize) {
setCacheManager(CacheManagerBuilder.newCacheManagerBuilder()
.using(PooledExecutionServiceConfigurationBuilder.newPooledExecutionServiceConfigurationBuilder()
.defaultPool("dflt", 0, 10)
.pool("defaultEventPool", 1, 3)
.pool("cache2Pool", 2, 2)
.build())
.withDefaultEventListenersThreadPool("defaultEventPool")
.withCache(cacheName, CacheConfigurationBuilder
.newCacheConfigurationBuilder(Long.class, byte[].class, ResourcePoolsBuilder.heap(cacheSize))
.build())
.build(true));
setCache(cacheManager.getCache(cacheName, Long.class, byte[].class));
}
示例2: dickPoolTest
import org.ehcache.config.builders.PooledExecutionServiceConfigurationBuilder; //导入依赖的package包/类
public void dickPoolTest() {
CacheManager cacheManager = CacheManagerBuilder.newCacheManagerBuilder()
.using(PooledExecutionServiceConfigurationBuilder.newPooledExecutionServiceConfigurationBuilder()
.defaultPool("dflt", 0, 10).pool("defaultDiskPool", 1, 3).pool("cache2Pool", 2, 2).build())
.with(new CacheManagerPersistenceConfiguration(new File(getStoragePath(), "myData")))
.withDefaultDiskStoreThreadPool("defaultDiskPool")
.withCache("cache1", CacheConfigurationBuilder.newCacheConfigurationBuilder(Long.class, String.class,
ResourcePoolsBuilder.newResourcePoolsBuilder().heap(10, EntryUnit.ENTRIES).disk(10L,
MemoryUnit.MB)))
.withCache("cache2",
CacheConfigurationBuilder.newCacheConfigurationBuilder(Long.class,
String.class, ResourcePoolsBuilder.newResourcePoolsBuilder().heap(10, EntryUnit.ENTRIES)
.disk(10L, MemoryUnit.MB))
.withDiskStoreThreadPool("cache2Pool", 2))
.build(true);
Cache<Long, String> cache1 = cacheManager.getCache("cache1", Long.class, String.class);
Cache<Long, String> cache2 = cacheManager.getCache("cache2", Long.class, String.class);
cacheManager.close();
}
示例3: eventsTest
import org.ehcache.config.builders.PooledExecutionServiceConfigurationBuilder; //导入依赖的package包/类
public void eventsTest() {
CacheManager cacheManager = CacheManagerBuilder.newCacheManagerBuilder()
.using(PooledExecutionServiceConfigurationBuilder.newPooledExecutionServiceConfigurationBuilder()
.pool("defaultEventPool", 1, 3).pool("cache2Pool", 2, 2).build())
.withDefaultEventListenersThreadPool(
"defaultEventPool")
.withCache("cache1",
CacheConfigurationBuilder
.newCacheConfigurationBuilder(Long.class, String.class,
ResourcePoolsBuilder.newResourcePoolsBuilder().heap(10, EntryUnit.ENTRIES))
.add(CacheEventListenerConfigurationBuilder.newEventListenerConfiguration(
new ListenerObject(), EventType.CREATED, EventType.UPDATED)))
.withCache("cache2", CacheConfigurationBuilder
.newCacheConfigurationBuilder(Long.class, String.class,
ResourcePoolsBuilder.newResourcePoolsBuilder().heap(10, EntryUnit.ENTRIES))
.add(CacheEventListenerConfigurationBuilder.newEventListenerConfiguration(new ListenerObject(),
EventType.CREATED, EventType.UPDATED))
.withEventListenersThreadPool("cache2Pool"))
.build(true);
Cache<Long, String> cache1 = cacheManager.getCache("cache1", Long.class, String.class);
Cache<Long, String> cache2 = cacheManager.getCache("cache2", Long.class, String.class);
cacheManager.close();
}
示例4: diskStore
import org.ehcache.config.builders.PooledExecutionServiceConfigurationBuilder; //导入依赖的package包/类
@Test
public void diskStore() throws Exception {
// tag::diskStore[]
CacheManager cacheManager
= CacheManagerBuilder.newCacheManagerBuilder()
.using(PooledExecutionServiceConfigurationBuilder.newPooledExecutionServiceConfigurationBuilder() // <1>
.defaultPool("dflt", 0, 10)
.pool("defaultDiskPool", 1, 3)
.pool("cache2Pool", 2, 2)
.build())
.with(new CacheManagerPersistenceConfiguration(new File(getStoragePath(), "myData")))
.withDefaultDiskStoreThreadPool("defaultDiskPool") // <2>
.withCache("cache1",
CacheConfigurationBuilder.newCacheConfigurationBuilder(Long.class, String.class,
ResourcePoolsBuilder.newResourcePoolsBuilder()
.heap(10, EntryUnit.ENTRIES)
.disk(10L, MemoryUnit.MB)))
.withCache("cache2",
CacheConfigurationBuilder.newCacheConfigurationBuilder(Long.class, String.class,
ResourcePoolsBuilder.newResourcePoolsBuilder()
.heap(10, EntryUnit.ENTRIES)
.disk(10L, MemoryUnit.MB))
.withDiskStoreThreadPool("cache2Pool", 2)) // <3>
.build(true);
Cache<Long, String> cache1 =
cacheManager.getCache("cache1", Long.class, String.class);
Cache<Long, String> cache2 =
cacheManager.getCache("cache2", Long.class, String.class);
cacheManager.close();
// end::diskStore[]
}
示例5: writeBehind
import org.ehcache.config.builders.PooledExecutionServiceConfigurationBuilder; //导入依赖的package包/类
@Test
public void writeBehind() throws Exception {
// tag::writeBehind[]
CacheManager cacheManager
= CacheManagerBuilder.newCacheManagerBuilder()
.using(PooledExecutionServiceConfigurationBuilder.newPooledExecutionServiceConfigurationBuilder() // <1>
.defaultPool("dflt", 0, 10)
.pool("defaultWriteBehindPool", 1, 3)
.pool("cache2Pool", 2, 2)
.build())
.withDefaultWriteBehindThreadPool("defaultWriteBehindPool") // <2>
.withCache("cache1",
CacheConfigurationBuilder.newCacheConfigurationBuilder(Long.class, String.class,
ResourcePoolsBuilder.newResourcePoolsBuilder().heap(10, EntryUnit.ENTRIES))
.withLoaderWriter(new SampleLoaderWriter<>(singletonMap(41L, "zero")))
.add(WriteBehindConfigurationBuilder
.newBatchedWriteBehindConfiguration(1, TimeUnit.SECONDS, 3)
.queueSize(3)
.concurrencyLevel(1)))
.withCache("cache2",
CacheConfigurationBuilder.newCacheConfigurationBuilder(Long.class, String.class,
ResourcePoolsBuilder.newResourcePoolsBuilder().heap(10, EntryUnit.ENTRIES))
.withLoaderWriter(new SampleLoaderWriter<>(singletonMap(41L, "zero")))
.add(WriteBehindConfigurationBuilder
.newBatchedWriteBehindConfiguration(1, TimeUnit.SECONDS, 3)
.useThreadPool("cache2Pool") // <3>
.queueSize(3)
.concurrencyLevel(2)))
.build(true);
Cache<Long, String> cache1 =
cacheManager.getCache("cache1", Long.class, String.class);
Cache<Long, String> cache2 =
cacheManager.getCache("cache2", Long.class, String.class);
cacheManager.close();
// end::writeBehind[]
}
示例6: events
import org.ehcache.config.builders.PooledExecutionServiceConfigurationBuilder; //导入依赖的package包/类
@Test
public void events() throws Exception {
// tag::events[]
CacheManager cacheManager
= CacheManagerBuilder.newCacheManagerBuilder()
.using(PooledExecutionServiceConfigurationBuilder.newPooledExecutionServiceConfigurationBuilder() // <1>
.pool("defaultEventPool", 1, 3)
.pool("cache2Pool", 2, 2)
.build())
.withDefaultEventListenersThreadPool("defaultEventPool") // <2>
.withCache("cache1",
CacheConfigurationBuilder.newCacheConfigurationBuilder(Long.class, String.class,
ResourcePoolsBuilder.newResourcePoolsBuilder().heap(10, EntryUnit.ENTRIES))
.add(CacheEventListenerConfigurationBuilder
.newEventListenerConfiguration(new ListenerObject(), EventType.CREATED, EventType.UPDATED)))
.withCache("cache2",
CacheConfigurationBuilder.newCacheConfigurationBuilder(Long.class, String.class,
ResourcePoolsBuilder.newResourcePoolsBuilder().heap(10, EntryUnit.ENTRIES))
.add(CacheEventListenerConfigurationBuilder
.newEventListenerConfiguration(new ListenerObject(), EventType.CREATED, EventType.UPDATED))
.withEventListenersThreadPool("cache2Pool")) // <3>
.build(true);
Cache<Long, String> cache1 =
cacheManager.getCache("cache1", Long.class, String.class);
Cache<Long, String> cache2 =
cacheManager.getCache("cache2", Long.class, String.class);
cacheManager.close();
// end::events[]
}
示例7: writeBehindTest
import org.ehcache.config.builders.PooledExecutionServiceConfigurationBuilder; //导入依赖的package包/类
public void writeBehindTest() {
CacheManager cacheManager = CacheManagerBuilder.newCacheManagerBuilder()
.using(PooledExecutionServiceConfigurationBuilder.newPooledExecutionServiceConfigurationBuilder()
.defaultPool("dflt", 0, 10).pool("defaultWriteBehindPool", 1, 3).pool("cache2Pool", 2, 2)
.build())
.withDefaultWriteBehindThreadPool("defaultWriteBehindPool")
.withCache("cache1", CacheConfigurationBuilder
.newCacheConfigurationBuilder(Long.class, String.class,
ResourcePoolsBuilder.newResourcePoolsBuilder().heap(10, EntryUnit.ENTRIES))
.withLoaderWriter(new SampleLoaderWriter<Long, String>(singletonMap(41L, "zero")))
.add(WriteBehindConfigurationBuilder.newBatchedWriteBehindConfiguration(1, TimeUnit.SECONDS, 3)
.queueSize(3).concurrencyLevel(1)))
.withCache("cache2",
CacheConfigurationBuilder
.newCacheConfigurationBuilder(Long.class, String.class,
ResourcePoolsBuilder.newResourcePoolsBuilder().heap(10, EntryUnit.ENTRIES))
.withLoaderWriter(new SampleLoaderWriter<Long, String>(singletonMap(41L, "zero")))
.add(WriteBehindConfigurationBuilder
.newBatchedWriteBehindConfiguration(1, TimeUnit.SECONDS, 3)
.useThreadPool("cache2Pool").queueSize(3).concurrencyLevel(2)))
.build(true);
Cache<Long, String> cache1 = cacheManager.getCache("cache1", Long.class, String.class);
Cache<Long, String> cache2 = cacheManager.getCache("cache2", Long.class, String.class);
cacheManager.close();
}