Java Code Examples for org.ehcache.config.CacheConfiguration#getKeyType()
The following examples show how to use
org.ehcache.config.CacheConfiguration#getKeyType() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EhcacheManager.java From ehcache3 with Apache License 2.0 | 4 votes |
private <K, V> Cache<K, V> createCache(String alias, CacheConfiguration<K, V> originalConfig, boolean addToConfig) throws IllegalArgumentException { statusTransitioner.checkAvailable(); LOGGER.debug("Creating Cache '{}' in {}.", alias, simpleName); CacheConfiguration<K, V> config = adjustConfigurationWithCacheManagerDefaults(alias, originalConfig); Class<K> keyType = config.getKeyType(); Class<V> valueType = config.getValueType(); CacheHolder value = new CacheHolder(keyType, valueType); if (caches.putIfAbsent(alias, value) != null) { throw new IllegalArgumentException("Cache '" + alias +"' already exists"); } InternalCache<K, V> cache = null; boolean success = false; RuntimeException failure = null; try { cache = createNewEhcache(alias, config, keyType, valueType); cache.init(); if (addToConfig) { configuration.addCacheConfiguration(alias, cache.getRuntimeConfiguration()); } else { configuration.replaceCacheConfiguration(alias, originalConfig, cache.getRuntimeConfiguration()); } success = true; } catch (RuntimeException e) { failure = e; } finally { if (!success) { caches.remove(alias); value.setCache(null); } } if(failure == null) { try { if(!statusTransitioner.isTransitioning()) { for (CacheManagerListener listener : listeners) { listener.cacheAdded(alias, cache); } } } finally { value.setCache(cache); } } else { throw new IllegalStateException("Cache '"+alias+"' creation in " + simpleName + " failed.", failure); } LOGGER.info("Cache '{}' created in {}.", alias, simpleName); return cache; }
Example 2
Source File: StoreConfigurationImpl.java From ehcache3 with Apache License 2.0 | 3 votes |
/** * Creates a new {@code StoreConfigurationImpl} based on the provided parameters. * * @param cacheConfig the cache configuration * @param dispatcherConcurrency the level of concurrency for ordered events * @param keySerializer the key serializer * @param valueSerializer the value serializer */ public StoreConfigurationImpl(CacheConfiguration<K, V> cacheConfig, int dispatcherConcurrency, Serializer<K> keySerializer, Serializer<V> valueSerializer) { this(cacheConfig.getKeyType(), cacheConfig.getValueType(), cacheConfig.getEvictionAdvisor(), cacheConfig.getClassLoader(), cacheConfig.getExpiryPolicy(), cacheConfig.getResourcePools(), dispatcherConcurrency, true, keySerializer, valueSerializer, null, false); }
Example 3
Source File: StoreConfigurationImpl.java From ehcache3 with Apache License 2.0 | 3 votes |
/** * Creates a new {@code StoreConfigurationImpl} based on the provided parameters. * * @param cacheConfig the cache configuration * @param dispatcherConcurrency the level of concurrency for ordered events * @param operationStatisticsEnabled if operation statistics should be enabled * @param keySerializer the key serializer * @param valueSerializer the value serializer */ public StoreConfigurationImpl(CacheConfiguration<K, V> cacheConfig, int dispatcherConcurrency, boolean operationStatisticsEnabled, Serializer<K> keySerializer, Serializer<V> valueSerializer, CacheLoaderWriter<? super K, V> cacheLoaderWriter, boolean useLoaderInAtomics) { this(cacheConfig.getKeyType(), cacheConfig.getValueType(), cacheConfig.getEvictionAdvisor(), cacheConfig.getClassLoader(), cacheConfig.getExpiryPolicy(), cacheConfig.getResourcePools(), dispatcherConcurrency, operationStatisticsEnabled, keySerializer, valueSerializer, cacheLoaderWriter, useLoaderInAtomics); }