Skip to content

Commit

Permalink
fix: fix cache invalidation introduced by commit f473617
Browse files Browse the repository at this point in the history
  • Loading branch information
ap891843 committed Jul 11, 2024
1 parent f0bf273 commit 7e02db9
Showing 1 changed file with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
import com.google.inject.Inject;
import com.google.inject.Singleton;
import com.google.inject.name.Named;

import java.util.List;
import java.util.Map;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
Expand Down Expand Up @@ -56,11 +59,17 @@ public void invalidateAll() {

/** Invalidates only non-implicit copybook cache */
public void invalidateAllNonImplicit() {
cache.invalidateAll(
List<CopybookId> toInvalidate =
cache.asMap().entrySet().stream()
.filter(entry -> entry.getValue().getUri() != null)
.filter(entry -> !ImplicitCodeUtils.isImplicit(entry.getValue().getUri()))
.collect(Collectors.toList()));
.filter(this::shouldInvalidate)
.map(Map.Entry::getKey)
.collect(Collectors.toList());
cache.invalidateAll(toInvalidate);
}

private boolean shouldInvalidate(Map.Entry<CopybookId, CopybookModel> entry) {
CopybookModel model = entry.getValue();
return model.getUri() == null || !ImplicitCodeUtils.isImplicit(model.getUri());
}

/**
Expand Down

0 comments on commit 7e02db9

Please sign in to comment.