public T getStatusFromCache()

in commit-status-publisher-server/src/main/java/jetbrains/buildServer/commitPublisher/CommitStatusesCache.java [72:101]


  public T getStatusFromCache(@NotNull BuildRevision revision, @Nullable String prefix,
                              @NotNull Supplier<Collection<T>> batchStatusLoader, @NotNull Function<T, String> prefixProvider) {
    if (!TeamCityProperties.getBooleanOrTrue(CACHE_FEATURE_TOGGLE_PARAMETER)) return null;

    ValueWithTTL<T> value = getStatusFromCache(revision, prefix);
    if (value != null && value.isAlive()) return value.getValue();
    Lock lock = myCacheLocks.get(revision.getRevision());
    lock.lock();
    try {
      value = getStatusFromCache(revision, prefix);
      if (value != null && value.isAlive()) return value.getValue();

      Collection<T> loadedStatuses = batchStatusLoader.get();
      if (loadedStatuses != null) {
        if (!loadedStatuses.isEmpty()) {
          putStatusesToCache(revision, loadedStatuses, prefixProvider);
        } else {
          putStatusToCache(revision, PREFIX_WILDCARD, null);
        }
      }
      value = getStatusFromCache(revision, prefix);
      if (value != null && value.isAlive()) return value.getValue();

      // probadly impossible case
      putStatusToCache(revision, prefix, null);
      return null;
    } finally {
      lock.unlock();
    }
  }