Java Code Examples for org.ehcache.config.CacheConfiguration#getEvictionAdvisor()

The following examples show how to use org.ehcache.config.CacheConfiguration#getEvictionAdvisor() . 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: CoreCacheConfigurationParser.java    From ehcache3 with Apache License 2.0 6 votes vote down vote up
public CacheType unparseConfiguration(CacheConfiguration<?, ?> cacheConfiguration, CacheType cacheType) {
  ExpiryPolicy<?, ?> expiryPolicy = cacheConfiguration.getExpiryPolicy();
  if (expiryPolicy != null) {
    Duration expiry = expiryPolicy.getExpiryForCreation(null, null);
    ExpiryType expiryType = new ExpiryType();
    if (expiryPolicy.equals(ExpiryPolicy.NO_EXPIRY)) {
      expiryType.withNone(new ExpiryType.None());
    } else if (expiryPolicy.equals(ExpiryPolicyBuilder.timeToLiveExpiration(expiry))) {
      expiryType.withTtl(convertToTimeType(expiry));
    } else if (expiryPolicy.equals(ExpiryPolicyBuilder.timeToIdleExpiration(expiry))) {
      expiryType.withTti(convertToTimeType(expiry));
    } else {
      throw new XmlConfigurationException("XML translation of custom expiry policy is not supported");
    }
    cacheType.withExpiry(expiryType);
  }

  EvictionAdvisor<?, ?> evictionAdvisor = cacheConfiguration.getEvictionAdvisor();
  if (evictionAdvisor != null) {
    throw new XmlConfigurationException("XML translation of eviction advisor is not supported");
  }

  return cacheType;
}
 
Example 2
Source File: StoreConfigurationImpl.java    From ehcache3 with Apache License 2.0 3 votes vote down vote up
/**
 * 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 vote down vote up
/**
 * 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);
}