public SymbolsCache()

in teamcity-symbol-server/src/main/java/jetbrains/buildServer/symbols/SymbolsCache.java [38:78]


  public SymbolsCache(@NotNull final EventDispatcher<BuildServerListener> events) {
    final int missedSymbolsCacheSize = TeamCityProperties.getInteger(SymbolsConstants.SYMBOLS_SERVER_MISS_CACHE_ENTRIES_SIZE, 2048);
    final int missedSymbolsExpirationTimeSec = TeamCityProperties.getInteger(SymbolsConstants.SYMBOLS_SERVER_MISS_CACHE_EXPIRATION_TIME_SEC, 60 * 60 * 3);

    myMissedSymbols = CacheBuilder
      .newBuilder()
      .maximumSize(missedSymbolsCacheSize)
      .expireAfterAccess(missedSymbolsExpirationTimeSec, TimeUnit.SECONDS)
      .build();

    final int cacheSize = TeamCityProperties.getInteger(SymbolsConstants.SYMBOLS_SERVER_CACHE_ENTRIES_SIZE, 32);
    final int expirationTimeSec = TeamCityProperties.getInteger(SymbolsConstants.SYMBOLS_SERVER_CACHE_EXPIRATION_TIME_SEC, 60 * 60);

    myCachedBuilds = CacheBuilder
      .newBuilder()
      .maximumSize(cacheSize)
      .expireAfterAccess(expirationTimeSec, TimeUnit.SECONDS)
      .removalListener((RemovalNotification<Long, Optional<Map<String, BuildMetadataEntry>>> notification) -> {
        LOG.debug("Removing cache entry. BuildId: " + notification.getValue());

        Optional<Map<String, BuildMetadataEntry>> notificationValue = notification.getValue();
        if (notificationValue == null || !notificationValue.isPresent()) {
          return;
        }

        for (String entryKey: notificationValue.get().keySet()) {
          LOG.debug("Removing entryKey: " + entryKey);
          myKeyToBuildIdMap.remove(entryKey);
        }

        LOG.debug("All build-related entries was removed from cache. BuildId: " + notification.getValue());
      })
      .build();

    events.addListener(new BuildServerAdapter() {
      @Override
      public void buildArtifactsChanged(@NotNull SBuild build) {
        myCachedBuilds.invalidate(build.getBuildId());
      }
    });
  }