Skip to content

Commit

Permalink
Surface clean cache
Browse files Browse the repository at this point in the history
  • Loading branch information
Friendseeker committed Nov 4, 2024
1 parent 3febd22 commit 6f1dae5
Showing 1 changed file with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,11 @@ static AnalysisStore sync(AnalysisStore analysisStore) {
*/
void set(AnalysisContents analysisContents);

/**
* Resets in memory cached {@link AnalysisContents}
*/
default void clearCache() {}

final class CachedAnalysisStore implements AnalysisStore {
private AnalysisStore underlying;
private Optional<AnalysisContents> lastStore = Optional.empty();
Expand All @@ -121,6 +126,10 @@ public void set(AnalysisContents analysisContents) {
underlying.set(analysisContents);
lastStore = Optional.of(analysisContents);
}

public void clearCache() {
lastStore = Optional.empty();
}
}

final class SyncedAnalysisStore implements AnalysisStore {
Expand All @@ -141,5 +150,11 @@ public void set(AnalysisContents analysisContents) {
underlying.set(analysisContents);
}
}

public void clearCache() {
if (underlying instanceof CachedAnalysisStore) {
underlying.clearCache();
}
}
}
}

0 comments on commit 6f1dae5

Please sign in to comment.