public static CacheConfig createCacheConfig(Properties properties) { // Heuristic caching boolean heuristicCachingEnabled = Parameters.HEURISTIC_CACHING_ENABLED.getValue(properties); float heuristicCoefficient = Parameters.HEURISTIC_COEFFICIENT.getValue(properties); long heuristicDefaultLifetimeSecs = Parameters.HEURISTIC_DEFAULT_LIFETIME_SECS.getValue(properties); int maxCacheEntries = Parameters.MAX_CACHE_ENTRIES.getValue(properties); long maxObjectSize = Parameters.MAX_OBJECT_SIZE.getValue(properties); // Asynchronous revalidation int minAsynchronousWorkers = Parameters.MIN_ASYNCHRONOUS_WORKERS.getValue(properties); int maxAsynchronousWorkers = Parameters.MAX_ASYNCHRONOUS_WORKERS.getValue(properties); int asynchronousWorkerIdleLifetimeSecs = Parameters.ASYNCHRONOUS_WORKER_IDLE_LIFETIME_SECS.getValue(properties); int maxUpdateRetries = Parameters.MAX_UPDATE_RETRIES.getValue(properties); int revalidationQueueSize = Parameters.REVALIDATION_QUEUE_SIZE.getValue(properties); CacheConfig.Builder builder = CacheConfig.custom(); builder.setHeuristicCachingEnabled(heuristicCachingEnabled); builder.setHeuristicCoefficient(heuristicCoefficient); builder.setHeuristicDefaultLifetime(heuristicDefaultLifetimeSecs); builder.setMaxCacheEntries(maxCacheEntries); long usedMaxObjectSize = Long.MAX_VALUE; if (maxObjectSize > 0) { usedMaxObjectSize = maxObjectSize; } builder.setMaxObjectSize(usedMaxObjectSize); builder.setAsynchronousWorkersCore(minAsynchronousWorkers); builder.setAsynchronousWorkersMax(maxAsynchronousWorkers); builder.setAsynchronousWorkerIdleLifetimeSecs(asynchronousWorkerIdleLifetimeSecs); builder.setMaxUpdateRetries(maxUpdateRetries).setRevalidationQueueSize(revalidationQueueSize); builder.setSharedCache(true); return builder.build(); }
public static Builder copy(final CacheConfig config) { Args.notNull(config, "Cache config"); return new Builder() .setMaxObjectSize(config.getMaxObjectSize()) .setMaxCacheEntries(config.getMaxCacheEntries()) .setMaxUpdateRetries(config.getMaxUpdateRetries()) .setHeuristicCachingEnabled(config.isHeuristicCachingEnabled()) .setHeuristicCoefficient(config.getHeuristicCoefficient()) .setHeuristicDefaultLifetime(config.getHeuristicDefaultLifetime()) .setSharedCache(config.isSharedCache()) .setAsynchronousWorkersMax(config.getAsynchronousWorkersMax()) .setAsynchronousWorkersCore(config.getAsynchronousWorkersCore()) .setAsynchronousWorkerIdleLifetimeSecs(config.getAsynchronousWorkerIdleLifetimeSecs()) .setRevalidationQueueSize(config.getRevalidationQueueSize()) .setNeverCacheHTTP10ResponsesWithQueryString(config.isNeverCacheHTTP10ResponsesWithQuery()); }