Exemplo n.º 1
0
  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);
  }
Exemplo n.º 2
0
 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;
 }
Exemplo n.º 3
0
  @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);
  }