Skip to content

Commit 5efa91f

Browse files
committed
Also on removeFromCache
1 parent 67f7b9a commit 5efa91f

File tree

1 file changed

+6
-4
lines changed
  • x-pack/plugin/searchable-snapshots/src/main/java/org/elasticsearch/xpack/searchablesnapshots/cache

1 file changed

+6
-4
lines changed

x-pack/plugin/searchable-snapshots/src/main/java/org/elasticsearch/xpack/searchablesnapshots/cache/CacheService.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,14 @@ public CacheFile get(final String name, final long length, final Path file) thro
9999
* @param predicate the predicate to evaluate
100100
*/
101101
public void removeFromCache(final Predicate<String> predicate) {
102-
for (String cacheKey : cache.keys()) {
103-
if (predicate.test(cacheKey)) {
104-
cache.invalidate(cacheKey);
102+
try (ReleasableLock ignored = cacheInvalidationLock.acquire()) {
103+
for (String cacheKey : cache.keys()) {
104+
if (predicate.test(cacheKey)) {
105+
cache.invalidate(cacheKey);
106+
}
105107
}
108+
cache.refresh();
106109
}
107-
cache.refresh();
108110
}
109111

110112
/**

0 commit comments

Comments
 (0)