Skip to content

Commit

Permalink
Re-added old versions of onCached and onRemoval to ShardRequestCache
Browse files Browse the repository at this point in the history
Signed-off-by: Peter Alfonsi <[email protected]>
  • Loading branch information
Peter Alfonsi committed Apr 29, 2024
1 parent 3030b81 commit bc553c7
Showing 1 changed file with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ public void onMiss() {
missCount.inc();
}

// Functions used to increment size by passing in the size directly, Used now, as we use ICacheKey<Key> in the IndicesRequestCache..
public void onCached(long keyRamBytesUsed, BytesReference value) {
totalMetric.inc(keyRamBytesUsed + value.ramBytesUsed());
}
Expand All @@ -75,4 +76,22 @@ public void onRemoval(long keyRamBytesUsed, BytesReference value, boolean evicte
}
totalMetric.dec(dec);
}

// Old functions which increment size by passing in an Accountable. Functional but no longer used.
public void onCached(Accountable key, BytesReference value) {
totalMetric.inc(key.ramBytesUsed() + value.ramBytesUsed());
}

public void onRemoval(Accountable key, BytesReference value, boolean evicted) {
if (evicted) {
evictionsMetric.inc();
}
long dec = 0;
if (key != null) {
dec += key.ramBytesUsed();
}
if (value != null) {
dec += value.ramBytesUsed();
}
}
}

0 comments on commit bc553c7

Please sign in to comment.