Skip to content

fix: reset memory usage on cache clear - #1309

Open
Aetherance wants to merge 1 commit into
foyer-rs:mainfrom
Aetherance:fix/clear-memory-usage
Open

fix: reset memory usage on cache clear#1309
Aetherance wants to merge 1 commit into
foyer-rs:mainfrom
Aetherance:fix/clear-memory-usage

Conversation

@Aetherance

Copy link
Copy Markdown

Summary

RawCache::clear() removed all cached entries but did not reset the per-shard memory usage. This left usage() and the memory usage metric with stale values and affected accounting after the cache was reused.

This PR resets the usage during cache clearing and updates the corresponding metric. It also adds a regression test covering normal clear, repeated clear, and insertion after clear.

ref: #973

Signed-off-by: Aetherance <inkToAether@gmail.com>
@Aetherance
Aetherance force-pushed the fix/clear-memory-usage branch from e31375d to ac0ec37 Compare July 20, 2026 02:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant