@Override public CacheEvictionConfig setEvictionPolicy(EvictionPolicy evictionPolicy) { super.setEvictionPolicy(evictionPolicy); return this; }
@Override public CacheEvictionConfig setEvictionPolicy(EvictionPolicy evictionPolicy) { super.setEvictionPolicy(evictionPolicy); return this; }
protected EvictionConfig createEvictionConfigWithEntryCountPolicy(int size) { return new EvictionConfig() .setEvictionPolicy(EvictionPolicy.LRU) .setMaximumSizePolicy(EvictionConfig.MaxSizePolicy.ENTRY_COUNT) .setSize(size); }
/** * Sets the eviction policy. * <p> * Valid values are: * <ul> * <li>{@code LRU} (Least Recently Used)</li> * <li>{@code LFU} (Least Frequently Used)</li> * <li>{@code NONE} (no extra eviction, time-to-live-seconds or max-idle-seconds may still apply)</li> * <li>{@code RANDOM} (random entry)</li> * </ul> * <p> * {@code LRU} is the default. * Regardless of the eviction policy used, time-to-live-seconds and max-idle-seconds will still apply. * * @param evictionPolicy the eviction policy for the Near Cache * @return this Near Cache config instance * @deprecated since 3.8, please use {@link #getEvictionConfig()} and {@link EvictionConfig#setEvictionPolicy(EvictionPolicy)} */ @Deprecated public NearCacheConfig setEvictionPolicy(String evictionPolicy) { this.evictionPolicy = checkNotNull(evictionPolicy, "Eviction policy cannot be null!"); this.evictionConfig.setEvictionPolicy(EvictionPolicy.valueOf(evictionPolicy)); this.evictionConfig.setMaximumSizePolicy(ENTRY_COUNT); return this; }
/** * Sets the eviction policy. * <p> * Valid values are: * <ul> * <li>{@code LRU} (Least Recently Used)</li> * <li>{@code LFU} (Least Frequently Used)</li> * <li>{@code NONE} (no extra eviction, time-to-live-seconds or max-idle-seconds may still apply)</li> * <li>{@code RANDOM} (random entry)</li> * </ul> * <p> * {@code LRU} is the default. * Regardless of the eviction policy used, time-to-live-seconds and max-idle-seconds will still apply. * * @param evictionPolicy the eviction policy for the Near Cache * @return this Near Cache config instance * @deprecated since 3.8, please use {@link #getEvictionConfig()} and {@link EvictionConfig#setEvictionPolicy(EvictionPolicy)} */ @Deprecated public NearCacheConfig setEvictionPolicy(String evictionPolicy) { this.evictionPolicy = checkNotNull(evictionPolicy, "Eviction policy cannot be null!"); this.evictionConfig.setEvictionPolicy(EvictionPolicy.valueOf(evictionPolicy)); this.evictionConfig.setMaximumSizePolicy(ENTRY_COUNT); return this; }
private EvictionConfig getEvictionConfig(Node node) { EvictionConfig evictionConfig = new EvictionConfig(); Node size = node.getAttributes().getNamedItem("size"); Node maxSizePolicy = node.getAttributes().getNamedItem("max-size-policy"); Node evictionPolicy = node.getAttributes().getNamedItem("eviction-policy"); if (size != null) { evictionConfig.setSize(Integer.parseInt(getTextContent(size))); } if (maxSizePolicy != null) { evictionConfig .setMaximumSizePolicy(EvictionConfig.MaxSizePolicy.valueOf(upperCaseInternal(getTextContent(maxSizePolicy))) ); } if (evictionPolicy != null) { evictionConfig.setEvictionPolicy(EvictionPolicy.valueOf(upperCaseInternal(getTextContent(evictionPolicy))) ); } return evictionConfig; }
private EvictionConfig getEvictionConfig(Node node) { EvictionConfig evictionConfig = new EvictionConfig(); Node size = node.getAttributes().getNamedItem("size"); Node maxSizePolicy = node.getAttributes().getNamedItem("max-size-policy"); Node evictionPolicy = node.getAttributes().getNamedItem("eviction-policy"); if (size != null) { evictionConfig.setSize(Integer.parseInt(getTextContent(size))); } if (maxSizePolicy != null) { evictionConfig.setMaximumSizePolicy(MaxSizePolicy.valueOf(upperCaseInternal(getTextContent(maxSizePolicy))) ); } if (evictionPolicy != null) { evictionConfig.setEvictionPolicy(EvictionPolicy.valueOf(upperCaseInternal(getTextContent(evictionPolicy))) ); } return evictionConfig; }
private EvictionConfig getEvictionConfig(final Node node) { final EvictionConfig evictionConfig = new EvictionConfig(); final Node size = node.getAttributes().getNamedItem("size"); final Node maxSizePolicy = node.getAttributes().getNamedItem("max-size-policy"); final Node evictionPolicy = node.getAttributes().getNamedItem("eviction-policy"); if (size != null) { evictionConfig.setSize(Integer.parseInt(getTextContent(size))); } if (maxSizePolicy != null) { evictionConfig.setMaximumSizePolicy( EvictionConfig.MaxSizePolicy.valueOf( upperCaseInternal(getTextContent(maxSizePolicy))) ); } if (evictionPolicy != null) { evictionConfig.setEvictionPolicy( EvictionPolicy.valueOf( upperCaseInternal(getTextContent(evictionPolicy))) ); } return evictionConfig; }
private EvictionConfig getEvictionConfig(final Node node) { final EvictionConfig evictionConfig = new EvictionConfig(); final Node size = node.getAttributes().getNamedItem("size"); final Node maxSizePolicy = node.getAttributes().getNamedItem("max-size-policy"); final Node evictionPolicy = node.getAttributes().getNamedItem("eviction-policy"); if (size != null) { evictionConfig.setSize(Integer.parseInt(getTextContent(size))); } if (maxSizePolicy != null) { evictionConfig.setMaximumSizePolicy( EvictionConfig.MaxSizePolicy.valueOf( upperCaseInternal(getTextContent(maxSizePolicy))) ); } if (evictionPolicy != null) { evictionConfig.setEvictionPolicy( EvictionPolicy.valueOf( upperCaseInternal(getTextContent(evictionPolicy))) ); } return evictionConfig; }
private EvictionConfig getEvictionConfig(Node node, boolean isNearCache) { EvictionConfig evictionConfig = new EvictionConfig(); Node size = node.getAttributes().getNamedItem("size"); Node maxSizePolicy = node.getAttributes().getNamedItem("max-size-policy"); Node evictionPolicy = node.getAttributes().getNamedItem("eviction-policy"); Node comparatorClassName = node.getAttributes().getNamedItem("comparator-class-name"); if (size != null) { evictionConfig.setSize(parseInt(getTextContent(size))); } if (maxSizePolicy != null) { evictionConfig.setMaximumSizePolicy(MaxSizePolicy.valueOf(upperCaseInternal(getTextContent(maxSizePolicy))) ); } if (evictionPolicy != null) { evictionConfig.setEvictionPolicy(EvictionPolicy.valueOf(upperCaseInternal(getTextContent(evictionPolicy))) ); } if (comparatorClassName != null) { evictionConfig.setComparatorClassName(getTextContent(comparatorClassName)); } try { checkEvictionConfig(evictionConfig, isNearCache); } catch (IllegalArgumentException e) { throw new InvalidConfigurationException(e.getMessage()); } return evictionConfig; }
private EvictionConfig getEvictionConfig(Node node, boolean isNearCache) { EvictionConfig evictionConfig = new EvictionConfig(); Node size = node.getAttributes().getNamedItem("size"); Node maxSizePolicy = node.getAttributes().getNamedItem("max-size-policy"); Node evictionPolicy = node.getAttributes().getNamedItem("eviction-policy"); Node comparatorClassName = node.getAttributes().getNamedItem("comparator-class-name"); if (size != null) { evictionConfig.setSize(parseInt(getTextContent(size))); } if (maxSizePolicy != null) { evictionConfig .setMaximumSizePolicy(EvictionConfig.MaxSizePolicy.valueOf(upperCaseInternal(getTextContent(maxSizePolicy))) ); } if (evictionPolicy != null) { evictionConfig.setEvictionPolicy(EvictionPolicy.valueOf(upperCaseInternal(getTextContent(evictionPolicy))) ); } if (comparatorClassName != null) { evictionConfig.setComparatorClassName(getTextContent(comparatorClassName)); } try { checkEvictionConfig(evictionConfig, isNearCache); } catch (IllegalArgumentException e) { throw new InvalidConfigurationException(e.getMessage()); } return evictionConfig; }
/** * @deprecated since 3.8, please use * {@link NearCacheConfig#NearCacheConfig(int, int, boolean, InMemoryFormat, EvictionConfig)} */ @Deprecated public NearCacheConfig(int timeToLiveSeconds, int maxSize, String evictionPolicy, int maxIdleSeconds, boolean invalidateOnChange, InMemoryFormat inMemoryFormat, EvictionConfig evictionConfig) { this.inMemoryFormat = inMemoryFormat; this.invalidateOnChange = invalidateOnChange; this.timeToLiveSeconds = timeToLiveSeconds; this.maxIdleSeconds = maxIdleSeconds; this.maxSize = calculateMaxSize(maxSize); this.evictionPolicy = evictionPolicy; // EvictionConfig is not allowed to be null if (evictionConfig != null) { this.evictionConfig = evictionConfig; } else { this.evictionConfig.setSize(calculateMaxSize(maxSize)); this.evictionConfig.setEvictionPolicy(EvictionPolicy.valueOf(evictionPolicy)); this.evictionConfig.setMaximumSizePolicy(ENTRY_COUNT); } }
/** * @deprecated since 3.8, please use * {@link NearCacheConfig#NearCacheConfig(int, int, boolean, InMemoryFormat, EvictionConfig)} */ @Deprecated public NearCacheConfig(int timeToLiveSeconds, int maxSize, String evictionPolicy, int maxIdleSeconds, boolean invalidateOnChange, InMemoryFormat inMemoryFormat, EvictionConfig evictionConfig) { this.inMemoryFormat = inMemoryFormat; this.invalidateOnChange = invalidateOnChange; this.timeToLiveSeconds = timeToLiveSeconds; this.maxIdleSeconds = maxIdleSeconds; this.maxSize = calculateMaxSize(maxSize); this.evictionPolicy = evictionPolicy; // EvictionConfig is not allowed to be null if (evictionConfig != null) { this.evictionConfig = evictionConfig; } else { this.evictionConfig.setSize(calculateMaxSize(maxSize)); this.evictionConfig.setEvictionPolicy(EvictionPolicy.valueOf(evictionPolicy)); this.evictionConfig.setMaximumSizePolicy(ENTRY_COUNT); } }
/** * Create a new {@link CacheConfig} with configured settings before {@link CacheManagerAware} implementor. */ private CacheConfig<?, ?> newCacheConfig(final String name) { final CacheConfig<?, ?> config = new CacheConfig<>(name); config.setEvictionConfig(new EvictionConfig().setEvictionPolicy(EvictionPolicy.LRU) .setMaximumSizePolicy(EvictionConfig.MaxSizePolicy.ENTRY_COUNT)); config.setExpiryPolicyFactory(AccessedExpiryPolicy.factoryOf(Duration.ETERNAL)); // Post configuration postConfigure(config); return config; }