Skip to content

Commit

Permalink
create IndicesRequestCacheCleanupManager
Browse files Browse the repository at this point in the history
Signed-off-by: Kiran Prakash <[email protected]>
  • Loading branch information
kiranprakash154 committed Mar 12, 2024
1 parent 0156877 commit 2d99197
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ public final class IndicesRequestCache implements RemovalListener<IndicesRequest
this.expire = INDICES_CACHE_QUERY_EXPIRE.exists(settings) ? INDICES_CACHE_QUERY_EXPIRE.get(settings) : null;
long sizeInBytes = size.getBytes();
ToLongBiFunction<Key, BytesReference> weigher = (k, v) -> k.ramBytesUsed() + v.ramBytesUsed();
this.cacheCleanupManager = new IndicesRequestCacheCleanupManager(getStalenessThreshold(settings));
this.cacheEntityLookup = cacheEntityFunction;
this.cache = cacheService.createCache(
new CacheConfig.Builder<Key, BytesReference>().setSettings(settings)
Expand All @@ -163,6 +164,11 @@ public void close() {
cache.invalidateAll();
}

private double getStalenessThreshold(Settings settings) {
String threshold = INDICES_REQUEST_CACHE_STALENESS_THRESHOLD_SETTING.get(settings);
return RatioValue.parseRatioValue(threshold).getAsRatio();
}

void clear(CacheEntity entity) {
cacheCleanupManager.enqueueCleanupKey(new CleanupKey(entity, null));
cacheCleanupManager.forceCleanCache();
Expand Down

0 comments on commit 2d99197

Please sign in to comment.