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

Java PersistentCacheManager类代码示例

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

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



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

示例1: CacheProvider

import org.ehcache.PersistentCacheManager; //导入依赖的package包/类
@Inject
public CacheProvider(Config config) {
    Objects.requireNonNull(config, Required.CONFIG.toString());
    
    if (config.isClusteredCached()) {
        CacheManagerBuilder<PersistentCacheManager> clusteredCacheManagerBuilder = CacheManagerBuilder.newCacheManagerBuilder() 
                .with(ClusteringServiceConfigurationBuilder.cluster(URI.create(config.getCacheClusterUrl())) 
                .autoCreate());

        this.cacheManager = clusteredCacheManagerBuilder.build(true);
    } else {
        this.cacheManager = CacheManagerBuilder.newCacheManagerBuilder().build();
        this.cacheManager.init();
    }

    initApplicationCache();
    initAuthenticationCache();
    initRequestCache();
    initServerEventCache();
    initWebSocketCache();
}
 
开发者ID:svenkubiak,项目名称:mangooio,代码行数:22,代码来源:CacheProvider.java


示例2: testStatefulSerializerWithDiskStateRepository

import org.ehcache.PersistentCacheManager; //导入依赖的package包/类
@Test
public void testStatefulSerializerWithDiskStateRepository() throws Exception {
  CacheManagerBuilder<PersistentCacheManager> cmBuilder = newCacheManagerBuilder().with(persistence(temporaryFolder.newFolder()
      .getAbsolutePath()))
      .withCache("myCache", newCacheConfigurationBuilder(Long.class, Person.class, heap(10).disk(50, MemoryUnit.MB, true))
          .withValueSerializer((Class) CompactJavaSerializer.class));
  PersistentCacheManager cacheManager = cmBuilder.build(true);

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

  myCache.put(42L, new Person("John", 42));
  myCache.put(35L, new Person("Marie", 35));

  cacheManager.close();

  cacheManager.init();

  myCache = cacheManager.getCache("myCache", Long.class, Person.class);

  assertThat(myCache.get(42L).getName(), is("John"));
}
 
开发者ID:ehcache,项目名称:ehcache3,代码行数:22,代码来源:StatefulSerializerWithStateRepositoryTest.java


示例3: testStatefulSerializerWithDiskStateRepositoryDifferentPersistenceServices

import org.ehcache.PersistentCacheManager; //导入依赖的package包/类
@Test
public void testStatefulSerializerWithDiskStateRepositoryDifferentPersistenceServices() throws Exception {
  CacheManagerBuilder<PersistentCacheManager> cmBuilder = newCacheManagerBuilder().with(persistence(temporaryFolder.newFolder()
      .getAbsolutePath()))
      .withCache("myCache", newCacheConfigurationBuilder(Long.class, Person.class, heap(10).disk(50, MemoryUnit.MB, true))
          .withValueSerializer((Class) CompactJavaSerializer.class));
  PersistentCacheManager cacheManager = cmBuilder.build(true);

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

  myCache.put(42L, new Person("John", 42));
  myCache.put(35L, new Person("Marie", 35));

  cacheManager.close();

  cacheManager = cmBuilder.build(true);

  myCache = cacheManager.getCache("myCache", Long.class, Person.class);

  assertThat(myCache.get(42L).getName(), is("John"));
}
 
开发者ID:ehcache,项目名称:ehcache3,代码行数:22,代码来源:StatefulSerializerWithStateRepositoryTest.java


示例4: test3TiersStoreStatsAvailableInContextManager

import org.ehcache.PersistentCacheManager; //导入依赖的package包/类
@Test
public void test3TiersStoreStatsAvailableInContextManager() throws Exception {
  PersistentCacheManager cacheManager = CacheManagerBuilder.newCacheManagerBuilder()
      .with(new CacheManagerPersistenceConfiguration(new File(getStoragePath(), "StoreStatisticsTest")))
      .withCache("threeTieredCache",
          CacheConfigurationBuilder.newCacheConfigurationBuilder(Long.class, String.class,
              newResourcePoolsBuilder()
                  .heap(1, MemoryUnit.MB)
                  .offheap(2, MemoryUnit.MB)
                  .disk(5, MemoryUnit.MB)
              )
      ).build(true);

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

  assertNull(cache.get(0L));

  long onHeapMisses = StoreStatisticsTest.<CachingTierOperationOutcomes.GetOrComputeIfAbsentOutcome>findStat(cache, "getOrComputeIfAbsent", "OnHeap").count(CachingTierOperationOutcomes.GetOrComputeIfAbsentOutcome.MISS);
  assertThat(onHeapMisses, equalTo(1L));
  long offHeapMisses = StoreStatisticsTest.<LowerCachingTierOperationsOutcome.GetAndRemoveOutcome>findStat(cache, "getAndRemove", "OffHeap").count(LowerCachingTierOperationsOutcome.GetAndRemoveOutcome.MISS);
  assertThat(offHeapMisses, equalTo(1L));
  long diskMisses = StoreStatisticsTest.<AuthoritativeTierOperationOutcomes.GetAndFaultOutcome>findStat(cache, "getAndFault", "Disk").count(AuthoritativeTierOperationOutcomes.GetAndFaultOutcome.MISS);
  assertThat(diskMisses, equalTo(1L));

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


示例5: threeTiersCacheManager

import org.ehcache.PersistentCacheManager; //导入依赖的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


示例6: diskSegments

import org.ehcache.PersistentCacheManager; //导入依赖的package包/类
@Test
public void diskSegments() throws Exception {
  // tag::diskSegments[]
  String storagePath = getStoragePath();
  PersistentCacheManager persistentCacheManager = CacheManagerBuilder.newCacheManagerBuilder()
    .with(CacheManagerBuilder.persistence(new File(storagePath, "myData")))
    .withCache("less-segments",
      CacheConfigurationBuilder.newCacheConfigurationBuilder(Long.class, String.class,
        ResourcePoolsBuilder.newResourcePoolsBuilder().disk(10, MemoryUnit.MB))
      .add(new OffHeapDiskStoreConfiguration(2)) // <1>
    )
    .build(true);

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


示例7: threeTiersCacheManager

import org.ehcache.PersistentCacheManager; //导入依赖的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


示例8: testIsExtensible

import org.ehcache.PersistentCacheManager; //导入依赖的package包/类
@Test
public void testIsExtensible() {

  AtomicInteger counter = new AtomicInteger(0);

  @SuppressWarnings("unchecked")
  CacheManagerConfiguration<PersistentCacheManager> managerConfiguration = other -> {
    counter.getAndIncrement();
    return mock(CacheManagerBuilder.class);
  };

  PersistentCacheManager cacheManager = newCacheManagerBuilder().with(managerConfiguration).build(true);

  assertThat(cacheManager).isNull();
  assertThat(counter.get()).isEqualTo(1);
}
 
开发者ID:ehcache,项目名称:ehcache3,代码行数:17,代码来源:CacheManagerBuilderTest.java


示例9: testPersistentDiskCache

import org.ehcache.PersistentCacheManager; //导入依赖的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


示例10: testClusteredCacheSingleClient

import org.ehcache.PersistentCacheManager; //导入依赖的package包/类
@Test
public void testClusteredCacheSingleClient() throws Exception {

  final CacheManagerBuilder<PersistentCacheManager> clusteredCacheManagerBuilder =
      newCacheManagerBuilder()
          .with(cluster(CLUSTER_URI).autoCreate())
          .withCache("clustered-cache", newCacheConfigurationBuilder(Long.class, String.class,
              ResourcePoolsBuilder.newResourcePoolsBuilder()
                  .with(clusteredDedicated("primary-server-resource", 2, MemoryUnit.MB))));
  final PersistentCacheManager cacheManager = clusteredCacheManagerBuilder.build(true);

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

  cache.put(1L, "value");
  assertThat(cache.get(1L), is("value"));

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


示例11: testTieredClusteredCache

import org.ehcache.PersistentCacheManager; //导入依赖的package包/类
@Test
public void testTieredClusteredCache() throws Exception {
  final CacheManagerBuilder<PersistentCacheManager> clusteredCacheManagerBuilder =
      newCacheManagerBuilder()
          .with(cluster(CLUSTER_URI).autoCreate())
          .withCache("clustered-cache", newCacheConfigurationBuilder(Long.class, String.class,
                  heap(2)
                  .with(clusteredDedicated("primary-server-resource", 2, MemoryUnit.MB))));
  final PersistentCacheManager cacheManager = clusteredCacheManagerBuilder.build(true);

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

  cache.put(1L, "value");
  assertThat(cache.get(1L), is("value"));

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


示例12: testClusteredCacheWithSerializableValue

import org.ehcache.PersistentCacheManager; //导入依赖的package包/类
@Test
public void testClusteredCacheWithSerializableValue() throws Exception {
  final CacheManagerBuilder<PersistentCacheManager> clusteredCacheManagerBuilder =
      newCacheManagerBuilder().with(cluster(CLUSTER_URI).autoCreate())
          .withCache("clustered-cache", newCacheConfigurationBuilder(Long.class, Person.class,
                  newResourcePoolsBuilder().with(clusteredDedicated("primary-server-resource", 2, MemoryUnit.MB))));
  PersistentCacheManager cacheManager = clusteredCacheManagerBuilder.build(true);

  Cache<Long, Person> cache = cacheManager.getCache("clustered-cache", Long.class, Person.class);

  cache.put(38L, new Person("Clustered Joe", 28));

  cacheManager.close();

  cacheManager = clusteredCacheManagerBuilder.build(true);
  cache = cacheManager.getCache("clustered-cache", Long.class, Person.class);

  assertThat(cache.get(38L).name, is("Clustered Joe"));
}
 
开发者ID:ehcache,项目名称:ehcache3,代码行数:20,代码来源:BasicClusteredCacheTest.java


示例13: testLargeValues

import org.ehcache.PersistentCacheManager; //导入依赖的package包/类
@Test
public void testLargeValues() throws Exception {
  DefaultStatisticsService statisticsService = new DefaultStatisticsService();
  CacheManagerBuilder<PersistentCacheManager> clusteredCacheManagerBuilder =
          newCacheManagerBuilder()
                  .using(statisticsService)
                  .with(cluster(CLUSTER_URI).autoCreate())
                  .withCache("small-cache", newCacheConfigurationBuilder(Long.class, BigInteger.class,
                          ResourcePoolsBuilder.newResourcePoolsBuilder()
                                  .with(clusteredDedicated("secondary-server-resource", 4, MemoryUnit.MB))));

  // The idea here is to add big things in the cache, and cause eviction of them to see if something crashes

  try(PersistentCacheManager cacheManager = clusteredCacheManagerBuilder.build(true)) {

    Cache<Long, BigInteger> cache = cacheManager.getCache("small-cache", Long.class, BigInteger.class);

    Random random = new Random();
    for (long i = 0; i < 100; i++) {
      BigInteger value = new BigInteger(30 * 1024 * 128 * (1 + random.nextInt(10)), random);
      cache.put(i, value);
    }
  }
}
 
开发者ID:ehcache,项目名称:ehcache3,代码行数:25,代码来源:BasicClusteredCacheTest.java


示例14: threeTiersCacheManager

import org.ehcache.PersistentCacheManager; //导入依赖的package包/类
@Test
public void threeTiersCacheManager() throws Exception {
  // tag::threeTiersCacheManager[]
  PersistentCacheManager persistentCacheManager = CacheManagerBuilder.newCacheManagerBuilder()
    .with(cluster(CLUSTER_URI).autoCreate()) // <1>
    .withCache("threeTierCache",
      CacheConfigurationBuilder.newCacheConfigurationBuilder(Long.class, String.class,
        ResourcePoolsBuilder.newResourcePoolsBuilder()
          .heap(10, EntryUnit.ENTRIES) // <2>
          .offheap(1, MemoryUnit.MB) // <3>
          .with(ClusteredResourcePoolBuilder.clusteredDedicated("primary-server-resource", 2, MemoryUnit.MB)) // <4>
      )
    ).build(true);
  // end::threeTiersCacheManager[]

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


示例15: clusteredCacheManagerWithServerSideConfigExample

import org.ehcache.PersistentCacheManager; //导入依赖的package包/类
@Test
public void clusteredCacheManagerWithServerSideConfigExample() throws Exception {
  // tag::clusteredCacheManagerWithServerSideConfigExample[]
  CacheManagerBuilder<PersistentCacheManager> clusteredCacheManagerBuilder =
      CacheManagerBuilder.newCacheManagerBuilder()
          .with(ClusteringServiceConfigurationBuilder.cluster(URI.create("terracotta://localhost/my-application")).autoCreate()
              .defaultServerResource("primary-server-resource") // <1>
              .resourcePool("resource-pool-a", 28, MemoryUnit.MB, "secondary-server-resource") // <2>
              .resourcePool("resource-pool-b", 32, MemoryUnit.MB)) // <3>
          .withCache("clustered-cache", CacheConfigurationBuilder.newCacheConfigurationBuilder(Long.class, String.class, // <4>
              ResourcePoolsBuilder.newResourcePoolsBuilder()
                  .with(ClusteredResourcePoolBuilder.clusteredDedicated("primary-server-resource", 32, MemoryUnit.MB)))) // <5>
          .withCache("shared-cache-1", CacheConfigurationBuilder.newCacheConfigurationBuilder(Long.class, String.class,
              ResourcePoolsBuilder.newResourcePoolsBuilder()
                  .with(ClusteredResourcePoolBuilder.clusteredShared("resource-pool-a")))) // <6>
          .withCache("shared-cache-2", CacheConfigurationBuilder.newCacheConfigurationBuilder(Long.class, String.class,
              ResourcePoolsBuilder.newResourcePoolsBuilder()
                  .with(ClusteredResourcePoolBuilder.clusteredShared("resource-pool-a")))); // <7>
  PersistentCacheManager cacheManager = clusteredCacheManagerBuilder.build(true); // <8>

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


示例16: clusteredCacheManagerWithDynamicallyAddedCacheExample

import org.ehcache.PersistentCacheManager; //导入依赖的package包/类
@Test
public void clusteredCacheManagerWithDynamicallyAddedCacheExample() throws Exception {
  // tag::clusteredCacheManagerWithDynamicallyAddedCacheExample[]
  CacheManagerBuilder<PersistentCacheManager> clusteredCacheManagerBuilder
          = CacheManagerBuilder.newCacheManagerBuilder()
          .with(ClusteringServiceConfigurationBuilder.cluster(URI.create("terracotta://localhost/my-application"))
                  .autoCreate()
                  .defaultServerResource("primary-server-resource")
                  .resourcePool("resource-pool-a", 28, MemoryUnit.MB));
  PersistentCacheManager cacheManager = clusteredCacheManagerBuilder.build(false);
  cacheManager.init();

  try {
    CacheConfiguration<Long, String> config = CacheConfigurationBuilder.newCacheConfigurationBuilder(Long.class, String.class,
            ResourcePoolsBuilder.newResourcePoolsBuilder()
                    .with(ClusteredResourcePoolBuilder.clusteredDedicated("primary-server-resource", 2, MemoryUnit.MB))).build();

    Cache<Long, String> cache = cacheManager.createCache("clustered-cache", config);

  } finally {
    cacheManager.close();
  }
  // end::clusteredCacheManagerWithDynamicallyAddedCacheExample[]
}
 
开发者ID:ehcache,项目名称:ehcache3,代码行数:25,代码来源:GettingStarted.java


示例17: testClusteredCacheWithLoaderWriter

import org.ehcache.PersistentCacheManager; //导入依赖的package包/类
@Test
public void testClusteredCacheWithLoaderWriter() {

  final CacheManagerBuilder<PersistentCacheManager> clusteredCacheManagerBuilder
      = CacheManagerBuilder.newCacheManagerBuilder()
      .with(ClusteringServiceConfigurationBuilder.cluster(URI.create("terracotta://localhost/my-application"))
          .autoCreate());
  final PersistentCacheManager cacheManager = clusteredCacheManagerBuilder.build(true);

  try {
    CacheConfiguration<Long, String> config = CacheConfigurationBuilder.newCacheConfigurationBuilder(Long.class, String.class,
        ResourcePoolsBuilder.newResourcePoolsBuilder()
            .with(ClusteredResourcePoolBuilder.clusteredDedicated("primary-server-resource", 8, MemoryUnit.MB)))
        .withLoaderWriter(new TestLoaderWriter())
        .build();

    cacheManager.createCache("test", config);
    fail("IllegalStateException expected");
  } catch (IllegalStateException e){
    assertThat(e.getCause().getMessage(), is("CacheLoaderWriter is not supported with clustered tiers"));
  }
  cacheManager.close();
}
 
开发者ID:ehcache,项目名称:ehcache3,代码行数:24,代码来源:UnSupportedCombinationsWIthClusteredCacheTest.java


示例18: testClusteredCacheWithXA

import org.ehcache.PersistentCacheManager; //导入依赖的package包/类
@Test
public void testClusteredCacheWithXA() throws Exception {
  TransactionManagerServices.getConfiguration().setJournal("null");

  BitronixTransactionManager transactionManager =
      TransactionManagerServices.getTransactionManager();

  PersistentCacheManager persistentCacheManager = null;
  try {
    CacheManagerBuilder.newCacheManagerBuilder()
        .using(new LookupTransactionManagerProviderConfiguration(BitronixTransactionManagerLookup.class))
        .with(ClusteringServiceConfigurationBuilder.cluster(URI.create("terracotta://localhost/my-application")).autoCreate())
        .withCache("xaCache", CacheConfigurationBuilder.newCacheConfigurationBuilder(Long.class, String.class,
            ResourcePoolsBuilder.newResourcePoolsBuilder()
                .with(ClusteredResourcePoolBuilder.clusteredDedicated("primary-server-resource", 8, MemoryUnit.MB))
            )
                .add(new XAStoreConfiguration("xaCache"))
                .build()
        )
        .build(true);
  } catch (StateTransitionException e) {
    assertThat(e.getCause().getCause().getMessage(), is("Unsupported resource type : interface org.ehcache.clustered.client.config.DedicatedClusteredResourcePool"));
  }

  transactionManager.shutdown();
}
 
开发者ID:ehcache,项目名称:ehcache3,代码行数:27,代码来源:UnSupportedCombinationsWIthClusteredCacheTest.java


示例19: testDestroyUnknownCacheAlias

import org.ehcache.PersistentCacheManager; //导入依赖的package包/类
@Test
public void testDestroyUnknownCacheAlias() throws Exception {
  clusteredCacheManagerBuilder.build(true).close();

  PersistentCacheManager cacheManager = newCacheManagerBuilder().with(cluster(CLUSTER_URI).expecting()).build(true);

  cacheManager.destroyCache(CLUSTERED_CACHE);

  try {
    cacheManager.createCache(CLUSTERED_CACHE, newCacheConfigurationBuilder(Long.class, String.class, newResourcePoolsBuilder()
        .with(clustered())));
    fail("Expected exception as clustered store no longer exists");
  } catch (IllegalStateException e) {
    assertThat(e.getMessage(), containsString(CLUSTERED_CACHE));
  }
  cacheManager.close();
}
 
开发者ID:ehcache,项目名称:ehcache3,代码行数:18,代码来源:ClusteredCacheDestroyTest.java


示例20: testGetNoExpirationPropagatedToHigherTiers

import org.ehcache.PersistentCacheManager; //导入依赖的package包/类
@Test
public void testGetNoExpirationPropagatedToHigherTiers() throws CachePersistenceException {
  CacheManagerBuilder<PersistentCacheManager> clusteredCacheManagerBuilder = cacheManagerBuilder(ExpiryPolicyBuilder.noExpiration());

  try(PersistentCacheManager cacheManager = clusteredCacheManagerBuilder.build(true)) {

    Map<String, TierStatistics> tierStatistics = statisticsService.getCacheStatistics(CLUSTERED_CACHE).getTierStatistics();
    TierStatistics onheap = tierStatistics.get("OnHeap");
    TierStatistics offheap = tierStatistics.get("OffHeap");

    Cache<Long, String> cache = cacheManager.getCache(CLUSTERED_CACHE, Long.class, String.class);
    for (long i = 0; i < 30; i++) {
      cache.put(i, "value"); // store on the cluster
      cache.get(i); // push it up on heap and offheap tier
    }

    assertThat(onheap.getMappings()).isEqualTo(10);
    assertThat(offheap.getMappings()).isEqualTo(20);
  }
}
 
开发者ID:ehcache,项目名称:ehcache3,代码行数:21,代码来源:ClusteredCacheExpirationTest.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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