void evict() { builder.eviction() .strategy(EvictionStrategy.valueOf(options.getString(Caching.CreateOption.EVICTION).toUpperCase())) .maxEntries(options.getInt(Caching.CreateOption.MAX_ENTRIES)); } void expire() {
/** * Creates a new ExoCache instance with the relevant parameters * @throws ExoCacheInitException If any exception occurs while creating the cache */ private ExoCache<Serializable, Object> create(ExoCacheConfig config, ConfigurationBuilder confBuilder, Callable<Cache<Serializable, Object>> cacheGetter, String strategy, int maxEntries, long lifespan, long maxIdle, long wakeUpInterval) throws ExoCacheInitException { EvictionStrategy es = strategy == null || strategy.length() == 0 ? null : EvictionStrategy.valueOf(strategy .toUpperCase(Locale.ENGLISH)); if (es == null) { es = EvictionStrategy.LRU; } confBuilder.eviction().strategy(EvictionStrategy.valueOf(strategy)).maxEntries(maxEntries).expiration() .lifespan(lifespan).maxIdle(maxIdle).wakeUpInterval(wakeUpInterval); try { return new GenericExoCache(config, cacheGetter.call()); } catch (Exception e)//NOSONAR { throw new ExoCacheInitException("Cannot create the cache '" + config.getName() + "'", e); } }
switch (attribute) { case STRATEGY: { enabled = EvictionStrategy.valueOf(value).isEnabled(); break;
final long size = MemoryObjectConfigurationResource.SIZE.resolveModelAttribute(context, node).asLong(); builder.memory().size(size); final EvictionStrategy strategy = EvictionStrategy.valueOf(MemoryObjectConfigurationResource.STRATEGY.resolveModelAttribute(context, node).asString()); builder.memory().evictionStrategy(strategy); } else if ((node = memoryNode.get(ModelKeys.BINARY_NAME)).isDefined()) { final long size = MemoryBinaryConfigurationResource.SIZE.resolveModelAttribute(context, node).asLong(); builder.memory().size(size); final EvictionStrategy strategy = EvictionStrategy.valueOf(MemoryObjectConfigurationResource.STRATEGY.resolveModelAttribute(context, node).asString()); builder.memory().evictionStrategy(strategy); final EvictionType type = EvictionType.valueOf(MemoryBinaryConfigurationResource.EVICTION.resolveModelAttribute(context, node).asString()); final long size = MemoryOffHeapConfigurationResource.SIZE.resolveModelAttribute(context, node).asLong(); builder.memory().size(size); final EvictionStrategy strategy = EvictionStrategy.valueOf(MemoryObjectConfigurationResource.STRATEGY.resolveModelAttribute(context, node).asString()); builder.memory().evictionStrategy(strategy); final EvictionType type = EvictionType.valueOf(MemoryOffHeapConfigurationResource.EVICTION.resolveModelAttribute(context, node).asString());