public PersistentCache( Path baseDir, long defaultDurationToExpireMs, Log log, boolean forceUpdate) { this.baseDir = baseDir; this.defaultDurationToExpireMs = defaultDurationToExpireMs; this.log = log; reconfigure(forceUpdate); log.debug("cache: " + baseDir + ", default expiration time (ms): " + defaultDurationToExpireMs); }
public WSLoader provide( AnalysisProperties props, AnalysisMode mode, PersistentCache cache, ServerClient client) { if (wsLoader == null) { // recreate cache directory if needed for this analysis cache.reconfigure(); wsLoader = new WSLoader(isCacheEnabled(props.properties(), mode.isPreview()), cache, client); wsLoader.setStrategy(getStrategy(mode)); } return wsLoader; }
@Test public void testReconfigure() throws Exception { cache = new PersistentCache(tmp.getRoot().toPath(), Long.MAX_VALUE, mock(Logger.class)); assertCacheHit(false); assertCacheHit(true); File root = tmp.getRoot(); FileUtils.deleteQuietly(root); // should re-create cache directory and start using the cache cache.reconfigure(); assertThat(root).exists(); assertCacheHit(false); assertCacheHit(true); }