本文整理汇总了Java中javax.cache.configuration.MutableConfiguration.setStoreByValue方法的典型用法代码示例。如果您正苦于以下问题:Java MutableConfiguration.setStoreByValue方法的具体用法?Java MutableConfiguration.setStoreByValue怎么用?Java MutableConfiguration.setStoreByValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.cache.configuration.MutableConfiguration
的用法示例。
在下文中一共展示了MutableConfiguration.setStoreByValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testCacheManagerWithCustomInvalidProperties
import javax.cache.configuration.MutableConfiguration; //导入方法依赖的package包/类
@Test(expected = IllegalArgumentException.class)
public void testCacheManagerWithCustomInvalidProperties()
throws Exception
{
Properties properties = new Properties();
properties.setProperty("unknownProperty", "true");
try (CacheManager cacheManager = cachingProvider.getCacheManager(null, null, properties);)
{
assertNotNull(cacheManager);
MutableConfiguration configuration = new MutableConfiguration();
configuration.setStoreByValue(false);
cacheManager.createCache("test", configuration);
}
}
示例2: testCreateCacheWithModifiedExpiryPolicy
import javax.cache.configuration.MutableConfiguration; //导入方法依赖的package包/类
@Test
public void testCreateCacheWithModifiedExpiryPolicy()
{
CacheManager cacheManager = cachingProvider.getCacheManager();
MutableConfiguration<Number, Number> configuration = new MutableConfiguration<>();
configuration.setStoreByValue(false);
configuration.setExpiryPolicyFactory(ModifiedExpiryPolicy.factoryOf(Duration.ONE_DAY));
Cache cache = cacheManager.createCache("cache", configuration);
CompleteConfiguration actualConfiguration =
(CompleteConfiguration) cache.getConfiguration(CompleteConfiguration.class);
assertEquals(ModifiedExpiryPolicy.factoryOf(Duration.ONE_DAY), actualConfiguration.getExpiryPolicyFactory());
}
示例3: testCreateCacheWithTouchedExpiryPolicy
import javax.cache.configuration.MutableConfiguration; //导入方法依赖的package包/类
@Test
public void testCreateCacheWithTouchedExpiryPolicy()
{
CacheManager cacheManager = cachingProvider.getCacheManager();
MutableConfiguration<Number, Number> configuration = new MutableConfiguration<>();
configuration.setStoreByValue(false);
configuration.setExpiryPolicyFactory(TouchedExpiryPolicy.factoryOf(Duration.ONE_MINUTE));
Cache cache = cacheManager.createCache("cache", configuration);
CompleteConfiguration actualConfiguration =
(CompleteConfiguration) cache.getConfiguration(CompleteConfiguration.class);
assertEquals(TouchedExpiryPolicy.factoryOf(Duration.ONE_MINUTE), actualConfiguration.getExpiryPolicyFactory());
}
示例4: getOrCreateCacheConfiguration
import javax.cache.configuration.MutableConfiguration; //导入方法依赖的package包/类
Configuration getOrCreateCacheConfiguration() {
if (configuration.getCacheConfiguration() != null) {
return configuration.getCacheConfiguration();
}
MutableConfiguration mutableConfiguration = new MutableConfiguration();
if (configuration.getCacheLoaderFactory() != null) {
mutableConfiguration.setCacheLoaderFactory(configuration.getCacheLoaderFactory());
}
if (configuration.getCacheWriterFactory() != null) {
mutableConfiguration.setCacheWriterFactory(configuration.getCacheWriterFactory());
}
if (configuration.getExpiryPolicyFactory() != null) {
mutableConfiguration.setExpiryPolicyFactory(configuration.getExpiryPolicyFactory());
}
mutableConfiguration.setManagementEnabled(configuration.isManagementEnabled());
mutableConfiguration.setStatisticsEnabled(configuration.isStatisticsEnabled());
mutableConfiguration.setReadThrough(configuration.isReadThrough());
mutableConfiguration.setStoreByValue(configuration.isStoreByValue());
return mutableConfiguration;
}
示例5: createConfiguration
import javax.cache.configuration.MutableConfiguration; //导入方法依赖的package包/类
@Override public <K, V> CompleteConfiguration<K, V> createConfiguration( Class<K> keyType, Class<V> valueType,
Map<String, String> properties ) {
MutableConfiguration<K, V> configuration = new MutableConfiguration<K, V>();
configuration.setTypes( keyType, valueType );
if ( properties.containsKey( CONFIG_TTL ) ) {
Long ttl = Longs.tryParse( Strings.nullToEmpty( properties.get( CONFIG_TTL ) ) );
Preconditions.checkArgument( ttl != null, "Template config error", CONFIG_TTL );
Optional<ExpiryFunction> expiryFunction;
if ( properties.containsKey( CONFIG_TTL_RESET ) ) {
expiryFunction = Enums.getIfPresent( ExpiryFunction.class, properties.get( CONFIG_TTL_RESET ) );
} else {
expiryFunction = Optional.of( CONFIG_TTL_RESET_DEFAULT );
}
Preconditions.checkArgument( expiryFunction.isPresent(), "Template config error", CONFIG_TTL_RESET );
configuration.setExpiryPolicyFactory( expiryFunction.get().createFactory( ttl ) );
}
if ( properties.containsKey( CONFIG_STORE_BY_VALUE ) ) {
configuration.setStoreByValue( Boolean.valueOf( properties.get( CONFIG_STORE_BY_VALUE ) ) );
}
return configuration;
}
示例6: createCacheConfiguration
import javax.cache.configuration.MutableConfiguration; //导入方法依赖的package包/类
/**
* Prep cache configuration.
*
* @param expiryDuration the expiry duration
* @return the mutable configuration
*/
protected static MutableConfiguration<String, Map<String, Object>> createCacheConfiguration(final Duration expiryDuration) {
final MutableConfiguration<String, Map<String, Object>> config = new MutableConfiguration<>();
config.setStatisticsEnabled(true);
config.setManagementEnabled(true);
config.setStoreByValue(true);
config.setExpiryPolicyFactory(CreatedExpiryPolicy.factoryOf(expiryDuration));
return config;
}
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:15,代码来源:CachingPrincipalAttributesRepository.java
示例7: testExpiration
import javax.cache.configuration.MutableConfiguration; //导入方法依赖的package包/类
@Test
public void testExpiration() throws InterruptedException, IllegalArgumentException, URISyntaxException, FailedToStartRedisException, IOException {
RedisProcess runner = new RedisRunner()
.nosave()
.randomDir()
.port(6311)
.run();
MutableConfiguration<String, String> config = new MutableConfiguration<>();
config.setExpiryPolicyFactory(CreatedExpiryPolicy.factoryOf(new Duration(TimeUnit.SECONDS, 1)));
config.setStoreByValue(true);
URI configUri = getClass().getResource("redisson-jcache.json").toURI();
Cache<String, String> cache = Caching.getCachingProvider().getCacheManager(configUri, null)
.createCache("test", config);
CountDownLatch latch = new CountDownLatch(1);
String key = "123";
ExpiredListener clientListener = new ExpiredListener(latch, key, "90");
MutableCacheEntryListenerConfiguration<String, String> listenerConfiguration =
new MutableCacheEntryListenerConfiguration<String, String>(FactoryBuilder.factoryOf(clientListener), null, true, true);
cache.registerCacheEntryListener(listenerConfiguration);
cache.put(key, "90");
Assert.assertNotNull(cache.get(key));
latch.await();
Assert.assertNull(cache.get(key));
cache.close();
runner.stop();
}
示例8: testCreateStoryByValueCache
import javax.cache.configuration.MutableConfiguration; //导入方法依赖的package包/类
@Test(expected = UnsupportedOperationException.class)
public void testCreateStoryByValueCache()
{
CacheManager cacheManager = cachingProvider.getCacheManager();
MutableConfiguration<Number, Number> configuration = new MutableConfiguration<>();
configuration.setStoreByValue(true);
cacheManager.createCache("cache", configuration);
}
示例9: testCreateReadThroughCacheWithInvalidConfiguration
import javax.cache.configuration.MutableConfiguration; //导入方法依赖的package包/类
@Test(expected = IllegalArgumentException.class)
public void testCreateReadThroughCacheWithInvalidConfiguration()
{
CacheManager cacheManager = cachingProvider.getCacheManager();
MutableConfiguration<Number, Number> configuration = new MutableConfiguration<>();
configuration.setStoreByValue(false);
configuration.setReadThrough(true);
cacheManager.createCache("cache", configuration);
}
示例10: testCreateWriteThroughCacheWithInvalidConfiguration
import javax.cache.configuration.MutableConfiguration; //导入方法依赖的package包/类
@Test(expected = UnsupportedOperationException.class)
public void testCreateWriteThroughCacheWithInvalidConfiguration()
{
CacheManager cacheManager = cachingProvider.getCacheManager();
MutableConfiguration<Number, Number> configuration = new MutableConfiguration<>();
configuration.setStoreByValue(false);
configuration.setWriteThrough(true);
cacheManager.createCache("cache", configuration);
}
示例11: testCreateCacheWithUnsupportedAccessedExpiryPolicy
import javax.cache.configuration.MutableConfiguration; //导入方法依赖的package包/类
@Test(expected = UnsupportedOperationException.class)
public void testCreateCacheWithUnsupportedAccessedExpiryPolicy()
{
CacheManager cacheManager = cachingProvider.getCacheManager();
MutableConfiguration<Number, Number> configuration = new MutableConfiguration<>();
configuration.setStoreByValue(false);
configuration.setExpiryPolicyFactory(AccessedExpiryPolicy.factoryOf(Duration.ZERO));
cacheManager.createCache("cache", configuration);
}
示例12: testCreateCacheWithUnsupportedCreatedExpiryPolicy
import javax.cache.configuration.MutableConfiguration; //导入方法依赖的package包/类
@Test(expected = UnsupportedOperationException.class)
public void testCreateCacheWithUnsupportedCreatedExpiryPolicy()
{
CacheManager cacheManager = cachingProvider.getCacheManager();
MutableConfiguration<Number, Number> configuration = new MutableConfiguration<>();
configuration.setStoreByValue(false);
configuration.setExpiryPolicyFactory(CreatedExpiryPolicy.factoryOf(Duration.ZERO));
cacheManager.createCache("cache", configuration);
}
示例13: jCacheManager
import javax.cache.configuration.MutableConfiguration; //导入方法依赖的package包/类
@Bean
public CacheManager jCacheManager() {
CacheManager cacheManager = this.cachingProvider.getCacheManager();
MutableConfiguration<Object, Object> mutableConfiguration = new MutableConfiguration<Object, Object>();
mutableConfiguration.setStoreByValue(false); // otherwise value has to be Serializable
cacheManager.createCache("testCache", mutableConfiguration);
cacheManager.createCache("primary", mutableConfiguration);
cacheManager.createCache("secondary", mutableConfiguration);
return cacheManager;
}
示例14: jCacheManager
import javax.cache.configuration.MutableConfiguration; //导入方法依赖的package包/类
@Bean
public CacheManager jCacheManager() {
CacheManager cacheManager = Caching.getCachingProvider().getCacheManager();
MutableConfiguration<Object, Object> mutableConfiguration = new MutableConfiguration<Object, Object>();
mutableConfiguration.setStoreByValue(false); // otherwise value has to be Serializable
cacheManager.createCache("primary", new JCacheConfiguration<Object, Object>(mutableConfiguration));
return cacheManager;
}
示例15: testCustomConfiguration
import javax.cache.configuration.MutableConfiguration; //导入方法依赖的package包/类
@Test
public void testCustomConfiguration() throws Exception {
boolean storeByValue = false;
MutableConfiguration configuration = new MutableConfiguration()
.setReadThrough(false).setWriteThrough(false).setStoreByValue(storeByValue)
.setTypes(java.math.BigDecimal.class, java.awt.Color.class)
.setManagementEnabled(true).setStatisticsEnabled(false);
Cache cache = null;
try
{
cache = getCacheManager().createCache("customCache", configuration);
} catch (UnsupportedOperationException e) {
storeByValue = true;
configuration.setStoreByValue(storeByValue);
cache = getCacheManager().createCache("customCache", configuration);
}
assertEquals("java.math.BigDecimal", lookupManagementAttribute(cache, CacheConfiguration, "KeyType"));
assertEquals("java.awt.Color", lookupManagementAttribute(cache, CacheConfiguration, "ValueType"));
assertEquals(false, lookupManagementAttribute(cache, CacheConfiguration, "ReadThrough"));
assertEquals(false, lookupManagementAttribute(cache, CacheConfiguration, "WriteThrough"));
assertEquals(storeByValue, lookupManagementAttribute(cache, CacheConfiguration, "StoreByValue"));
assertEquals(false, lookupManagementAttribute(cache, CacheConfiguration, "StatisticsEnabled"));
assertEquals(true, lookupManagementAttribute(cache, CacheConfiguration, "ManagementEnabled"));
//this used to just call close() but that does not work if an implementation maintains statistics on the cluster.
cache.getCacheManager().destroyCache("customCache");
}