本文整理汇总了Java中org.ehcache.jsr107.EhcacheCachingProvider类的典型用法代码示例。如果您正苦于以下问题:Java EhcacheCachingProvider类的具体用法?Java EhcacheCachingProvider怎么用?Java EhcacheCachingProvider使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EhcacheCachingProvider类属于org.ehcache.jsr107包,在下文中一共展示了EhcacheCachingProvider类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: before
import org.ehcache.jsr107.EhcacheCachingProvider; //导入依赖的package包/类
@Before
public void before() throws Exception {
CachingProvider cachingProvider = Caching.getCachingProvider();
EhcacheCachingProvider ehcacheProvider = (EhcacheCachingProvider) cachingProvider;
DefaultConfiguration configuration = new DefaultConfiguration(ehcacheProvider.getDefaultClassLoader(),
new DefaultPersistenceConfiguration(diskPath.newFolder()));
CacheConfiguration<Integer, String> cacheConfiguration =
CacheConfigurationBuilder.newCacheConfigurationBuilder(Integer.class, String.class, resources).build();
configuration.addCacheConfiguration("cache", cacheConfiguration);
cacheManager = ehcacheProvider.getCacheManager(ehcacheProvider.getDefaultURI(), configuration);
EhcacheManager ehcacheManager = cacheManager.unwrap(EhcacheManager.class);
Field field = EhcacheManager.class.getDeclaredField("serviceLocator");
field.setAccessible(true);
@SuppressWarnings("unchecked")
ServiceProvider<Service> serviceProvider = (ServiceProvider<Service>)field.get(ehcacheManager);
StatisticsService statisticsService = serviceProvider.getService(StatisticsService.class);
cache = cacheManager.getCache("cache", Integer.class, String.class);
cacheStatistics = statisticsService.getCacheStatistics("cache");
}
开发者ID:ehcache,项目名称:ehcache3,代码行数:26,代码来源:JCacheCalculationTest.java
示例2: ehCacheManager
import org.ehcache.jsr107.EhcacheCachingProvider; //导入依赖的package包/类
@Bean
@Primary
public CacheManager ehCacheManager(JiraSyncConfig jiraSyncConfig) throws Exception {
CachingProvider cachingProvider = Caching.getCachingProvider();
EhcacheCachingProvider ehcacheCachingProvider = (EhcacheCachingProvider) cachingProvider;
CacheConfig cacheConfig = jiraSyncConfig.getCache();
CacheManager cacheManager = getCacheManager(ehcacheCachingProvider, cacheConfig);
boolean persistentCache = cacheConfig.isPersistent();
createCache(cacheManager, CACHE_NAME_PROJECTS, ONE_HOUR, persistentCache);
createCache(cacheManager, CACHE_NAME_PRIORITIES, ONE_HOUR, persistentCache);
createCache(cacheManager, CACHE_NAME_RESOLUTIONS, ONE_HOUR, persistentCache);
createCache(cacheManager, CACHE_NAME_VERSIONS, ONE_HOUR, persistentCache);
createCache(cacheManager, CACHE_NAME_FIELDS, ONE_HOUR, persistentCache);
createCache(cacheManager, CACHE_NAME_REMOTE_LINKS, ONE_HOUR, persistentCache);
createCache(cacheManager, CACHE_NAME_USERS, ONE_HOUR, persistentCache);
createCache(cacheManager, CACHE_NAME_FIELD_ALLOWED_VALUES, ONE_HOUR, persistentCache);
createCache(cacheManager, CACHE_NAME_MYSELF, ONE_HOUR, false);
createCache(cacheManager, CACHE_NAME_SERVER_INFO, THIRTY_SECONDS, false);
return cacheManager;
}
开发者ID:cronn-de,项目名称:jira-sync,代码行数:21,代码来源:JiraServiceCacheConfig.java
示例3: cacheManager
import org.ehcache.jsr107.EhcacheCachingProvider; //导入依赖的package包/类
@Bean
public CacheManager cacheManager(@Autowired Config config) {
long ttl = Long.valueOf(config.getProperties().getProperty(Config.PROP_CACHE_TTL));
double pctOfHeap = Double.valueOf(config.getProperties().getProperty(Config.PROP_CACHE_SIZE));
long cacheSizeMB = new Double(Runtime.getRuntime().maxMemory() * pctOfHeap / 1048576.0).longValue();
LogFactory.getLog(getClass()).info(
String.format("Initializing cache TTL=%d secs, size=%d MB (%.2f percent of max heap)",
ttl, cacheSizeMB, pctOfHeap * 100));
org.ehcache.config.CacheConfiguration<Object, Object> cacheConfiguration = CacheConfigurationBuilder
.newCacheConfigurationBuilder(Object.class, Object.class,
ResourcePoolsBuilder.newResourcePoolsBuilder()
.heap(cacheSizeMB, MemoryUnit.MB))
.withExpiry(Expirations.timeToLiveExpiration(new org.ehcache.expiry.Duration(ttl, TimeUnit.SECONDS)))
.build();
Map<String, CacheConfiguration<?, ?>> caches = new HashMap<>();
caches.put(CACHE_DEFAULT, cacheConfiguration);
EhcacheCachingProvider provider = (EhcacheCachingProvider) javax.cache.Caching.getCachingProvider();
// when our cacheManager bean is re-created several times for
// diff test configurations, this provider seems to hang on to state
// causing cache settings to not be right. so we always close().
provider.close();
DefaultConfiguration configuration = new DefaultConfiguration(
caches, provider.getDefaultClassLoader());
return new JCacheCacheManager(
provider.getCacheManager(provider.getDefaultURI(), configuration));
}
开发者ID:codeforkjeff,项目名称:conciliator,代码行数:35,代码来源:Application.java
示例4: createInMemoryCacheManager
import org.ehcache.jsr107.EhcacheCachingProvider; //导入依赖的package包/类
private CacheManager createInMemoryCacheManager() {
long cacheSize = properties.getCache().getEhcache().getSize();
long ttl = properties.getCache().getEhcache().getTimeToLiveSeconds();
org.ehcache.config.CacheConfiguration<Object, Object> cacheConfiguration = CacheConfigurationBuilder
.newCacheConfigurationBuilder(Object.class, Object.class, ResourcePoolsBuilder
.newResourcePoolsBuilder()
.heap(cacheSize))
.withExpiry(Expirations.timeToLiveExpiration(new org.ehcache.expiry.Duration(ttl, TimeUnit.SECONDS)))
.build();
Map<String, org.ehcache.config.CacheConfiguration<?, ?>> caches = createCacheConfigurations(cacheConfiguration);
EhcacheCachingProvider provider = getCachingProvider();
DefaultConfiguration configuration = new DefaultConfiguration(caches, provider.getDefaultClassLoader());
return provider.getCacheManager(provider.getDefaultURI(), configuration);
}
开发者ID:ehcache,项目名称:ehcache3-samples,代码行数:18,代码来源:CacheConfiguration.java
示例5: getCacheConfiguration
import org.ehcache.jsr107.EhcacheCachingProvider; //导入依赖的package包/类
private DefaultConfiguration getCacheConfiguration(EhcacheCachingProvider cachingProvider, CacheConfig cacheConfig) {
if (cacheConfig.isPersistent()) {
Path cacheDirectory = Paths.get(cacheConfig.getDirectory());
log.info("setting up persistent cache in {}", cacheDirectory.toAbsolutePath());
DefaultPersistenceConfiguration persistenceConfiguration = new DefaultPersistenceConfiguration(cacheDirectory.toFile());
return new DefaultConfiguration(cachingProvider.getDefaultClassLoader(), persistenceConfiguration);
} else {
log.info("setting up in-memory cache");
return new DefaultConfiguration(cachingProvider.getDefaultClassLoader());
}
}
开发者ID:cronn-de,项目名称:jira-sync,代码行数:12,代码来源:JiraServiceCacheConfig.java
示例6: ehcache3AsJCacheWithCaches
import org.ehcache.jsr107.EhcacheCachingProvider; //导入依赖的package包/类
@Test
public void ehcache3AsJCacheWithCaches() {
String cachingProviderFqn = EhcacheCachingProvider.class.getName();
load(DefaultCacheConfiguration.class, "spring.cache.type=jcache",
"spring.cache.jcache.provider=" + cachingProviderFqn,
"spring.cache.cacheNames[0]=foo", "spring.cache.cacheNames[1]=bar");
JCacheCacheManager cacheManager = validateCacheManager(JCacheCacheManager.class);
assertThat(cacheManager.getCacheNames()).containsOnly("foo", "bar");
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:10,代码来源:CacheAutoConfigurationTests.java
示例7: ehcache3AsJCacheWithConfig
import org.ehcache.jsr107.EhcacheCachingProvider; //导入依赖的package包/类
@Test
public void ehcache3AsJCacheWithConfig() throws IOException {
String cachingProviderFqn = EhcacheCachingProvider.class.getName();
String configLocation = "ehcache3.xml";
load(DefaultCacheConfiguration.class, "spring.cache.type=jcache",
"spring.cache.jcache.provider=" + cachingProviderFqn,
"spring.cache.jcache.config=" + configLocation);
JCacheCacheManager cacheManager = validateCacheManager(JCacheCacheManager.class);
Resource configResource = new ClassPathResource(configLocation);
assertThat(cacheManager.getCacheManager().getURI())
.isEqualTo(configResource.getURI());
assertThat(cacheManager.getCacheNames()).containsOnly("foo", "bar");
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:15,代码来源:CacheAutoConfigurationTests.java
示例8: createClusteredCacheManager
import org.ehcache.jsr107.EhcacheCachingProvider; //导入依赖的package包/类
private CacheManager createClusteredCacheManager() {
JHipsterProperties.Cache.Ehcache.Cluster clusterProperties = properties.getCache().getEhcache().getCluster();
URI clusterUri = clusterProperties.getUri();
boolean autoCreate = clusterProperties.isAutoCreate();
long clusteredCacheSize = clusterProperties.getSizeInMb();
Consistency consistency = clusterProperties.getConsistency();
long heapCacheSize = properties.getCache().getEhcache().getSize();
long ttl = properties.getCache().getEhcache().getTimeToLiveSeconds();
ClusteringServiceConfigurationBuilder clusteringServiceConfigurationBuilder = ClusteringServiceConfigurationBuilder.cluster(clusterUri);
ServerSideConfigurationBuilder serverSideConfigurationBuilder = (autoCreate ? clusteringServiceConfigurationBuilder.autoCreate() : clusteringServiceConfigurationBuilder.expecting())
.defaultServerResource("primary-server-resource");
org.ehcache.config.CacheConfiguration<Object, Object> cacheConfiguration = CacheConfigurationBuilder
.newCacheConfigurationBuilder(Object.class, Object.class, ResourcePoolsBuilder
.newResourcePoolsBuilder()
.heap(heapCacheSize)
.with(ClusteredResourcePoolBuilder.clusteredDedicated(clusteredCacheSize, MemoryUnit.MB)))
.withExpiry(Expirations.timeToLiveExpiration(new org.ehcache.expiry.Duration(ttl, TimeUnit.SECONDS)))
.add(new ClusteredStoreConfiguration(consistency)).build();
Map<String, org.ehcache.config.CacheConfiguration<?, ?>> caches = createCacheConfigurations(cacheConfiguration);
EhcacheCachingProvider provider = getCachingProvider();
DefaultConfiguration configuration = new DefaultConfiguration(caches, provider.getDefaultClassLoader(), serverSideConfigurationBuilder.build());
return provider.getCacheManager(provider.getDefaultURI(), configuration);
}
开发者ID:ehcache,项目名称:ehcache3-samples,代码行数:29,代码来源:CacheConfiguration.java
示例9: create
import org.ehcache.jsr107.EhcacheCachingProvider; //导入依赖的package包/类
private CacheManager create(@Nullable final URI config) {
CachingProvider provider = Caching.getCachingProvider(
EhcacheCachingProvider.class.getName(),
EhcacheCachingProvider.class.getClassLoader()
);
log.info("Creating cache-manager with configuration: {}", config);
CacheManager manager = provider.getCacheManager(config, getClass().getClassLoader());
log.debug("Created cache-manager: {}", manager);
return manager;
}
开发者ID:sonatype,项目名称:nexus-public,代码行数:12,代码来源:EhCacheManagerProvider.java
示例10: testCacheManagerLevelConfiguration
import org.ehcache.jsr107.EhcacheCachingProvider; //导入依赖的package包/类
@Test
public void testCacheManagerLevelConfiguration() throws Exception {
// tag::ehcacheCacheManagerConfigurationExample[]
CachingProvider cachingProvider = Caching.getCachingProvider();
EhcacheCachingProvider ehcacheProvider = (EhcacheCachingProvider) cachingProvider; // <1>
DefaultConfiguration configuration = new DefaultConfiguration(ehcacheProvider.getDefaultClassLoader(),
new DefaultPersistenceConfiguration(getPersistenceDirectory())); // <2>
CacheManager cacheManager = ehcacheProvider.getCacheManager(ehcacheProvider.getDefaultURI(), configuration); // <3>
// end::ehcacheCacheManagerConfigurationExample[]
assertThat(cacheManager, notNullValue());
}
开发者ID:ehcache,项目名称:ehcache3,代码行数:15,代码来源:EhCache107ConfigurationIntegrationDocTest.java
示例11: cachingProviders
import org.ehcache.jsr107.EhcacheCachingProvider; //导入依赖的package包/类
private static Stream<CachingProvider> cachingProviders() {
return Stream.of(
new RICachingProvider(),
new EhcacheCachingProvider()
);
}
开发者ID:micrometer-metrics,项目名称:micrometer,代码行数:7,代码来源:JCacheMetricsTest.java
示例12: getCacheManager
import org.ehcache.jsr107.EhcacheCachingProvider; //导入依赖的package包/类
private CacheManager getCacheManager(EhcacheCachingProvider cachingProvider, CacheConfig cacheConfig) {
URI uri = cachingProvider.getDefaultURI();
DefaultConfiguration configuration = getCacheConfiguration(cachingProvider, cacheConfig);
return cachingProvider.getCacheManager(uri, configuration);
}
开发者ID:cronn-de,项目名称:jira-sync,代码行数:6,代码来源:JiraServiceCacheConfig.java
示例13: getCachingProvider
import org.ehcache.jsr107.EhcacheCachingProvider; //导入依赖的package包/类
private EhcacheCachingProvider getCachingProvider() {
return (EhcacheCachingProvider) Caching.getCachingProvider();
}
开发者ID:ehcache,项目名称:ehcache3-samples,代码行数:4,代码来源:CacheConfiguration.java
注:本文中的org.ehcache.jsr107.EhcacheCachingProvider类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论