• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java EntryUnit类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.ehcache.config.units.EntryUnit的典型用法代码示例。如果您正苦于以下问题:Java EntryUnit类的具体用法?Java EntryUnit怎么用?Java EntryUnit使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



EntryUnit类属于org.ehcache.config.units包,在下文中一共展示了EntryUnit类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: ServerInterfaceCache

import org.ehcache.config.units.EntryUnit; //导入依赖的package包/类
private ServerInterfaceCache() {
	this.cacheManager = CacheManagerBuilder.newCacheManagerBuilder().withCache("airports",
			CacheConfigurationBuilder.newCacheConfigurationBuilder(String.class, String.class,
					ResourcePoolsBuilder.newResourcePoolsBuilder()
					.heap(10, EntryUnit.ENTRIES)
					.offheap(10, MemoryUnit.MB)) 
			)
			.build(true);
	this.airportCache = this.cacheManager.getCache("airports", String.class, String.class);
	this.airplaneCache = this.cacheManager.createCache("airplanes",
			CacheConfigurationBuilder.newCacheConfigurationBuilder(String.class, String.class, 
					ResourcePoolsBuilder.newResourcePoolsBuilder()
					.heap(10, EntryUnit.ENTRIES)
					.offheap(10, MemoryUnit.MB)).build());
	this.flightCache = this.cacheManager.createCache("flights", 
			CacheConfigurationBuilder.newCacheConfigurationBuilder(String.class, String.class, 
					ResourcePoolsBuilder.newResourcePoolsBuilder()
					.heap(10, EntryUnit.ENTRIES)
					.offheap(10, MemoryUnit.MB)).build());
}
 
开发者ID:king-jam,项目名称:cs509,代码行数:21,代码来源:ServerInterfaceCache.java


示例2: createRegistry

import org.ehcache.config.units.EntryUnit; //导入依赖的package包/类
@Override
protected JndiRegistry createRegistry() throws Exception {
    JndiRegistry registry = super.createRegistry();
    registry.bind(
        "myConf",
        CacheConfigurationBuilder.newCacheConfigurationBuilder(
            String.class,
            String.class,
            ResourcePoolsBuilder.newResourcePoolsBuilder()
                .heap(100, EntryUnit.ENTRIES)
                .offheap(1, MemoryUnit.MB))
        .build()
    );

    return registry;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:17,代码来源:EhcacheConfigurationTest.java


示例3: testProgrammaticConfiguration

import org.ehcache.config.units.EntryUnit; //导入依赖的package包/类
@Test
public void testProgrammaticConfiguration() throws Exception {
    EhcacheManager manager = ehcacheConf.getManager();
    Cache<String, String> cache = manager.getCache("myCacheConf", String.class, String.class);

    ResourcePools pools = cache.getRuntimeConfiguration().getResourcePools();

    SizedResourcePool h = pools.getPoolForResource(ResourceType.Core.HEAP);
    assertNotNull(h);
    assertEquals(100, h.getSize());
    assertEquals(EntryUnit.ENTRIES, h.getUnit());

    SizedResourcePool o = pools.getPoolForResource(ResourceType.Core.OFFHEAP);
    assertNotNull(o);
    assertEquals(1, o.getSize());
    assertEquals(MemoryUnit.MB, o.getUnit());
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:18,代码来源:EhcacheConfigurationTest.java


示例4: testOffHeapClientClass

import org.ehcache.config.units.EntryUnit; //导入依赖的package包/类
@Test
public void testOffHeapClientClass() {
  CacheManager cacheManager = CacheManagerBuilder.newCacheManagerBuilder()
      .withClassLoader(getClass().getClassLoader())
      .withCache("myCache", newCacheConfigurationBuilder(Long.class, Order.class, newResourcePoolsBuilder().heap(10, EntryUnit.ENTRIES).offheap(2, MemoryUnit.MB))
          .build())
      .build(true);

  Cache<Long, Order> cache = cacheManager.getCache("myCache", Long.class, Order.class);

  Order order = new Order(42L);
  cache.put(42L, order);

  assertTrue(cache.get(42L) instanceof Order);

  cache.replace(42L, order, new Order(-1L));

  assertEquals(-1L, cache.get(42L).id);
}
 
开发者ID:ehcache,项目名称:ehcache3,代码行数:20,代码来源:OffHeapOsgiTest.java


示例5: testEventOrderForUpdateThatTriggersEviction

import org.ehcache.config.units.EntryUnit; //导入依赖的package包/类
@Test
public void testEventOrderForUpdateThatTriggersEviction () {
  CacheConfiguration<Long, SerializableObject> cacheConfiguration = newCacheConfigurationBuilder(Long.class, SerializableObject.class,
      newResourcePoolsBuilder()
          .heap(1L, EntryUnit.ENTRIES).offheap(1l, MemoryUnit.MB).build()).build();

  CacheManager cacheManager = CacheManagerBuilder.newCacheManagerBuilder().withCache("cache", cacheConfiguration)
      .build(true);
  Cache<Long, SerializableObject> cache = cacheManager.getCache("cache", Long.class, SerializableObject.class);
  cache.getRuntimeConfiguration().registerCacheEventListener(listener1, EventOrdering.ORDERED, EventFiring.SYNCHRONOUS, EnumSet
      .of(EventType.EVICTED, EventType.CREATED, EventType.UPDATED, EventType.REMOVED));
  SerializableObject object1 = new SerializableObject(0xAAE60);     // 700 KB
  SerializableObject object2 = new SerializableObject(0xDBBA0);     // 900 KB

  cache.put(1L, object1);
  cache.put(1L, object2);
  assertThat(listener1.eventTypeHashMap.get(EventType.EVICTED), lessThan(listener1.eventTypeHashMap.get(EventType.CREATED)));

  cacheManager.close();
}
 
开发者ID:ehcache,项目名称:ehcache3,代码行数:21,代码来源:EventNotificationTest.java


示例6: test_eviction

import org.ehcache.config.units.EntryUnit; //导入依赖的package包/类
@Test
public void test_eviction() throws Exception {
  UserManagedCache<Number, String> cache = UserManagedCacheBuilder.newUserManagedCacheBuilder(Number.class, String.class)
      .withResourcePools(newResourcePoolsBuilder().heap(1, EntryUnit.ENTRIES))
      .build(true);
  assertThat(cache.getRuntimeConfiguration().getResourcePools().getPoolForResource(ResourceType.Core.HEAP).getSize(),
      equalTo(1L));

  // we put 3 elements, but there's only capacity for 1
  for (int i = 0; i < 3; i++) {
    cache.putIfAbsent(i, "" + i);
  }

  // we must find at most 1 non empty value
  int nullValuesFound = 0;
  for (int i = 0; i < 3; i++) {
    String retrievedValue = cache.get(i);
    if (retrievedValue == null) {
      nullValuesFound ++;
    }
  }
  assertThat("The capacity of the store is 1, and we found more than 1 non empty value in it !", nullValuesFound, is(2));
}
 
开发者ID:ehcache,项目名称:ehcache3,代码行数:24,代码来源:UserManagedCacheEvictionTest.java


示例7: eventsTest

import org.ehcache.config.units.EntryUnit; //导入依赖的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();
}
 
开发者ID:dzh,项目名称:jframe,代码行数:26,代码来源:TestThreadPool.java


示例8: setUp

import org.ehcache.config.units.EntryUnit; //导入依赖的package包/类
@Before
public void setUp() {
  transactionManagerWrapper = new TransactionManagerWrapper(testTransactionManager, new NullXAResourceRegistry());
  classLoader = ClassLoader.getSystemClassLoader();
  keySerializer = new JavaSerializer<>(classLoader);
  valueSerializer = new JavaSerializer<>(classLoader);
  CopyProvider copyProvider = new DefaultCopyProvider(new DefaultCopyProviderConfiguration());
  keyCopier = copyProvider.createKeyCopier(Long.class, keySerializer);
  valueCopier = copyProvider.createValueCopier(valueClass, valueSerializer);
  Store.Configuration<Long, SoftLock<String>> onHeapConfig = new StoreConfigurationImpl<>(Long.class, valueClass,
    null, classLoader, ExpiryPolicyBuilder.noExpiration(), ResourcePoolsBuilder.newResourcePoolsBuilder()
    .heap(10, EntryUnit.ENTRIES)
    .build(),
    0, keySerializer, valueSerializer);
  testTimeSource = new TestTimeSource();
  eventDispatcher = NullStoreEventDispatcher.nullStoreEventDispatcher();
  onHeapStore = new OnHeapStore<>(onHeapConfig, testTimeSource, keyCopier, valueCopier, new NoopSizeOfEngine(), eventDispatcher);
  journal = new TransientJournal<>();
}
 
开发者ID:ehcache,项目名称:ehcache3,代码行数:20,代码来源:XAStoreTest.java


示例9: threeTiersCacheManager

import org.ehcache.config.units.EntryUnit; //导入依赖的package包/类
@Test
public void threeTiersCacheManager() throws Exception {
  // tag::threeTiersCacheManager[]
  PersistentCacheManager persistentCacheManager = CacheManagerBuilder.newCacheManagerBuilder()
    .with(CacheManagerBuilder.persistence(new File(getStoragePath(), "myData")))
    .withCache("threeTieredCache",
      CacheConfigurationBuilder.newCacheConfigurationBuilder(Long.class, String.class,
        ResourcePoolsBuilder.newResourcePoolsBuilder()
          .heap(10, EntryUnit.ENTRIES)
          .offheap(1, MemoryUnit.MB)
          .disk(20, MemoryUnit.MB, true)
      )
    ).build(true);
  // end::threeTiersCacheManager[]

  persistentCacheManager.close();
}
 
开发者ID:ehcache,项目名称:ehcache3,代码行数:18,代码来源:Tiering.java


示例10: userManagedDiskCache

import org.ehcache.config.units.EntryUnit; //导入依赖的package包/类
@Test
public void userManagedDiskCache() throws Exception {
  // tag::persistentUserManagedCache[]
  LocalPersistenceService persistenceService = new DefaultLocalPersistenceService(new DefaultPersistenceConfiguration(new File(getStoragePath(), "myUserData"))); // <1>

  PersistentUserManagedCache<Long, String> cache = UserManagedCacheBuilder.newUserManagedCacheBuilder(Long.class, String.class)
      .with(new UserManagedPersistenceContext<>("cache-name", persistenceService)) // <2>
      .withResourcePools(ResourcePoolsBuilder.newResourcePoolsBuilder()
          .heap(10L, EntryUnit.ENTRIES)
          .disk(10L, MemoryUnit.MB, true)) // <3>
      .build(true);

  // Work with the cache
  cache.put(42L, "The Answer!");
  assertThat(cache.get(42L), is("The Answer!"));

  cache.close(); // <4>
  cache.destroy(); // <5>

  persistenceService.stop(); // <6>
  // end::persistentUserManagedCache[]
}
 
开发者ID:ehcache,项目名称:ehcache3,代码行数:23,代码来源:UserManagedCaches.java


示例11: userManagedListenerCache

import org.ehcache.config.units.EntryUnit; //导入依赖的package包/类
@Test
public void userManagedListenerCache() throws Exception {
  // tag::userManagedListenerCache[]

  UserManagedCache<Long, String> cache = UserManagedCacheBuilder.newUserManagedCacheBuilder(Long.class, String.class)
      .withEventExecutors(Executors.newSingleThreadExecutor(), Executors.newFixedThreadPool(5)) // <1>
      .withEventListeners(CacheEventListenerConfigurationBuilder
          .newEventListenerConfiguration(ListenerObject.class, EventType.CREATED, EventType.UPDATED)
          .asynchronous()
          .unordered()) // <2>
      .withResourcePools(ResourcePoolsBuilder.newResourcePoolsBuilder()
          .heap(3, EntryUnit.ENTRIES))
      .build(true);

  cache.put(1L, "Put it");
  cache.put(1L, "Update it");

  cache.close();
  // end::userManagedListenerCache[]
}
 
开发者ID:ehcache,项目名称:ehcache3,代码行数:21,代码来源:UserManagedCaches.java


示例12: threeTiersCacheManager

import org.ehcache.config.units.EntryUnit; //导入依赖的package包/类
@Test
public void threeTiersCacheManager() throws Exception {
  // tag::threeTiersCacheManager[]
  PersistentCacheManager persistentCacheManager = CacheManagerBuilder.newCacheManagerBuilder()
      .with(CacheManagerBuilder.persistence(new File(getStoragePath(), "myData"))) // <1>
      .withCache("threeTieredCache",
          CacheConfigurationBuilder.newCacheConfigurationBuilder(Long.class, String.class,
              ResourcePoolsBuilder.newResourcePoolsBuilder()
                  .heap(10, EntryUnit.ENTRIES) // <2>
                  .offheap(1, MemoryUnit.MB) // <3>
                  .disk(20, MemoryUnit.MB, true) // <4>
              )
      ).build(true);

  Cache<Long, String> threeTieredCache = persistentCacheManager.getCache("threeTieredCache", Long.class, String.class);
  threeTieredCache.put(1L, "stillAvailableAfterRestart"); // <5>

  persistentCacheManager.close();
  // end::threeTiersCacheManager[]
}
 
开发者ID:ehcache,项目名称:ehcache3,代码行数:21,代码来源:GettingStarted.java


示例13: testTieredStore

import org.ehcache.config.units.EntryUnit; //导入依赖的package包/类
@Test
public void testTieredStore() throws Exception {
  CacheConfiguration<Long, String> tieredCacheConfiguration = CacheConfigurationBuilder.newCacheConfigurationBuilder(Long.class, String.class,
      ResourcePoolsBuilder.newResourcePoolsBuilder().heap(10, EntryUnit.ENTRIES).disk(10L, MemoryUnit.MB))
      .build();

  CacheManager cacheManager = CacheManagerBuilder.newCacheManagerBuilder()
      .with(new CacheManagerPersistenceConfiguration(new File(System.getProperty("java.io.tmpdir") + "/tiered-cache-data")))
      .withCache("tiered-cache", tieredCacheConfiguration).build(true);

  Cache<Long, String> tieredCache = cacheManager.getCache("tiered-cache", Long.class, String.class);

  tieredCache.put(1L, "one");

  assertThat(tieredCache.get(1L), equalTo("one")); // probably coming from disk
  assertThat(tieredCache.get(1L), equalTo("one")); // probably coming from heap

  cacheManager.close();
}
 
开发者ID:ehcache,项目名称:ehcache3,代码行数:20,代码来源:TieringTest.java


示例14: testTieredOffHeapStore

import org.ehcache.config.units.EntryUnit; //导入依赖的package包/类
@Test
public void testTieredOffHeapStore() throws Exception {
  CacheConfiguration<Long, String> tieredCacheConfiguration = CacheConfigurationBuilder.newCacheConfigurationBuilder(Long.class, String.class,
      ResourcePoolsBuilder.newResourcePoolsBuilder().heap(10, EntryUnit.ENTRIES).offheap(10, MemoryUnit.MB))
      .build();

  CacheManager cacheManager = CacheManagerBuilder.newCacheManagerBuilder().withCache("tieredCache", tieredCacheConfiguration).build(true);

  Cache<Long, String> tieredCache = cacheManager.getCache("tieredCache", Long.class, String.class);

  tieredCache.put(1L, "one");

  assertThat(tieredCache.get(1L), equalTo("one")); // probably coming from offheap
  assertThat(tieredCache.get(1L), equalTo("one")); // probably coming from heap

  cacheManager.close();
}
 
开发者ID:ehcache,项目名称:ehcache3,代码行数:18,代码来源:TieringTest.java


示例15: testPersistentDiskCache

import org.ehcache.config.units.EntryUnit; //导入依赖的package包/类
@Test
  public void testPersistentDiskCache() throws Exception {
    CacheConfiguration<Long, String> cacheConfiguration = CacheConfigurationBuilder.newCacheConfigurationBuilder(Long.class, String.class,
        ResourcePoolsBuilder.newResourcePoolsBuilder().heap(10, EntryUnit.ENTRIES).disk(10L, MemoryUnit.MB, true))
        .build();

    PersistentCacheManager persistentCacheManager = CacheManagerBuilder.newCacheManagerBuilder()
        .with(new CacheManagerPersistenceConfiguration(new File(getClass().getClassLoader().getResource(".").toURI().getPath() + "/../../persistent-cache-data")))
        .withCache("persistent-cache", cacheConfiguration)
        .build(true);

    Cache<Long, String> cache = persistentCacheManager.getCache("persistent-cache", Long.class, String.class);

    // Comment the following line on subsequent run and see the test pass
    cache.put(42L, "That's the answer!");
    assertThat(cache.get(42L), is("That's the answer!"));

    // Uncomment the following line to nuke the disk store
//    persistentCacheManager.destroyCache("persistent-cache");

    persistentCacheManager.close();
  }
 
开发者ID:ehcache,项目名称:ehcache3,代码行数:23,代码来源:TieringTest.java


示例16: testCreateCacheWithSameAliasAfterDestroy

import org.ehcache.config.units.EntryUnit; //导入依赖的package包/类
@Test
public void testCreateCacheWithSameAliasAfterDestroy() throws URISyntaxException, CachePersistenceException {
  File file = new File(getStoragePath(), "testDestroy");
  initCacheManager(file);

  persistentCacheManager.destroyCache(PERSISTENT_CACHE);

  persistentCacheManager.createCache(PERSISTENT_CACHE, CacheConfigurationBuilder.newCacheConfigurationBuilder(Long.class, String.class,
      newResourcePoolsBuilder()
          .heap(10, EntryUnit.ENTRIES)
          .disk(10L, MemoryUnit.MB, true))
      .build());

  assertNotNull(persistentCacheManager.getCache(PERSISTENT_CACHE, Long.class, String.class));

  persistentCacheManager.close();
}
 
开发者ID:ehcache,项目名称:ehcache3,代码行数:18,代码来源:CacheManagerDestroyRemovesPersistenceTest.java


示例17: testOffHeapPutGet

import org.ehcache.config.units.EntryUnit; //导入依赖的package包/类
@Test
public void testOffHeapPutGet() {
  Cache<Long, String> cache = cacheManager.createCache("offHeap", newCacheConfigurationBuilder(Long.class, String.class,
                                        newResourcePoolsBuilder().heap(10, EntryUnit.ENTRIES).offheap(10, MemoryUnit.MB))
          .build()
  );

  cache.put(42L, "TheAnswer");
  assertCounters(1, 0, 0, 1, 0, 0);
  printSerializationCounters("Put Offheap");
  cache.get(42L);
  assertCounters(0, 0, 1, 0, 1, 0);
  printSerializationCounters("Get Offheap fault");
  cache.get(42L);
  assertCounters(0, 0, 0, 0, 0, 0);
  printSerializationCounters("Get Offheap faulted");

  cache.put(42L, "Wrong ...");
  assertCounters(1, 0, 2, 1, 0, 0);
  printSerializationCounters("Put OffHeap (update faulted)");
}
 
开发者ID:ehcache,项目名称:ehcache3,代码行数:22,代码来源:SerializerCountingTest.java


示例18: testOffHeapOnHeapCopyPutGet

import org.ehcache.config.units.EntryUnit; //导入依赖的package包/类
@Test
public void testOffHeapOnHeapCopyPutGet() {
  Cache<Long, String> cache = cacheManager.createCache("offHeap", newCacheConfigurationBuilder(Long.class, String.class,
                                        newResourcePoolsBuilder().heap(10, EntryUnit.ENTRIES).offheap(10, MemoryUnit.MB))
          .add(new DefaultCopierConfiguration<>(SerializingCopier.<Long>asCopierClass(), DefaultCopierConfiguration.Type.KEY))
          .add(new DefaultCopierConfiguration<>(SerializingCopier.<String>asCopierClass(), DefaultCopierConfiguration.Type.VALUE))
          .build()
  );

  cache.put(42L, "TheAnswer");
  assertCounters(2, 1, 0, 1, 0, 0);
  printSerializationCounters("Put OffheapOnHeapCopy");
  cache.get(42L);
  assertCounters(1, 1, 1, 0, 2, 0);
  printSerializationCounters("Get OffheapOnHeapCopy fault");
  cache.get(42L);
  assertCounters(0, 0, 0, 0, 1, 0);
  printSerializationCounters("Get OffheapOnHeapCopy faulted");

  cache.put(42L, "Wrong ...");
  assertCounters(3, 2, 2, 1, 0, 0);
  printSerializationCounters("Put OffheapOnHeapCopy (update faulted)");
}
 
开发者ID:ehcache,项目名称:ehcache3,代码行数:24,代码来源:SerializerCountingTest.java


示例19: testDiskOffHeapOnHeapCopyPutGet

import org.ehcache.config.units.EntryUnit; //导入依赖的package包/类
@Test
public void testDiskOffHeapOnHeapCopyPutGet() {
  Cache<Long, String> cache = cacheManager.createCache("offHeap", newCacheConfigurationBuilder(Long.class, String.class,
                newResourcePoolsBuilder().heap(2, EntryUnit.ENTRIES).offheap(10, MemoryUnit.MB).disk(100, MemoryUnit.MB))
          .add(new DefaultCopierConfiguration<>(SerializingCopier.<Long>asCopierClass(), DefaultCopierConfiguration.Type.KEY))
          .add(new DefaultCopierConfiguration<>(SerializingCopier.<String>asCopierClass(), DefaultCopierConfiguration.Type.VALUE))
          .build()
  );


  cache.put(42L, "TheAnswer");
  assertCounters(3, 2, 0, 1, 0, 0);
  printSerializationCounters("Put DiskOffHeapOnHeapCopy");
  cache.get(42L);
  assertCounters(1, 1, 1, 0, 2, 0);
  printSerializationCounters("Get DiskOffHeapOnHeapCopy fault");
  cache.get(42L);
  assertCounters(0, 0, 0, 0, 1, 0);
  printSerializationCounters("Get DiskOffHeapOnHeapCopy faulted");

  cache.put(42L, "Wrong ...");
  assertCounters(3, 2, 2, 1, 0, 0);
  printSerializationCounters("Put DiskOffHeapOnHeapCopy (update faulted)");
}
 
开发者ID:ehcache,项目名称:ehcache3,代码行数:25,代码来源:SerializerCountingTest.java


示例20: testUpdateResources

import org.ehcache.config.units.EntryUnit; //导入依赖的package包/类
@Test
public void testUpdateResources() {
  CacheConfiguration<Long, String> cacheConfiguration = CacheConfigurationBuilder.newCacheConfigurationBuilder(Long.class, String.class,
      ResourcePoolsBuilder.newResourcePoolsBuilder()
          .heap(10L, EntryUnit.ENTRIES).disk(10, MemoryUnit.MB).build()).build();

  final CacheManager cacheManager = CacheManagerBuilder.newCacheManagerBuilder()
      .with(new CacheManagerPersistenceConfiguration(new File(System.getProperty("java.io.tmpdir") + "/myData")))
      .withCache("cache", cacheConfiguration).build(true);

  Cache<Long, String> cache = cacheManager.getCache("cache", Long.class, String.class);

  ResourcePoolsBuilder poolsBuilder = ResourcePoolsBuilder.newResourcePoolsBuilder();
  poolsBuilder = poolsBuilder.heap(20L, EntryUnit.ENTRIES);
  ResourcePools pools = poolsBuilder.build();
  cache.getRuntimeConfiguration().updateResourcePools(pools);
  assertThat(cache.getRuntimeConfiguration().getResourcePools()
      .getPoolForResource(ResourceType.Core.HEAP).getSize(), is(20L));
  pools = poolsBuilder.build();
  cache.getRuntimeConfiguration().updateResourcePools(pools);
  assertThat(cache.getRuntimeConfiguration().getResourcePools()
      .getPoolForResource(ResourceType.Core.HEAP).getSize(), is(20L));
  cacheManager.close();
}
 
开发者ID:ehcache,项目名称:ehcache3,代码行数:25,代码来源:EhcacheRuntimeConfigurationTest.java



注:本文中的org.ehcache.config.units.EntryUnit类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java GetContainersRequest类代码示例发布时间:2022-05-22
下一篇:
Java MessageHandler类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap