Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Brush up the eviction handler implementation #14

Open
tatsuya6502 opened this issue Aug 11, 2023 · 2 comments
Open

Brush up the eviction handler implementation #14

tatsuya6502 opened this issue Aug 11, 2023 · 2 comments
Labels
enhancement New feature or request
Milestone

Comments

@tatsuya6502
Copy link
Member

tatsuya6502 commented Aug 11, 2023

As of now (commit #f7a15e24), the following issues might be present with the eviction handler:

  1. invalidate an existing entry will always trigger the eviction handler with RemovalCause::Explicit.
    • a. But there are chances that entry has been already expired. In such case, the eviction handler should be triggered with RemovalCause::Expired.
    • b. The same thing applies to invalidate_all.
  2. There is no code path for RemovalCause::Replaced.
    • a. We should also select RemovalCause::Replaced or RemovalCause::Expired based on the expiration status of the entry.

For 1-a and 2-a, see moka's this unit test: moka sync/cache.rs#L4270-L4280

@tatsuya6502
Copy link
Member Author

tatsuya6502 commented Aug 11, 2023

Also an internal do_upsert_with_hash method should check whether the existing entry is expired or not. If expired, it should skip to call the update closure.

let mut old_value = entry.value.clone();
update(&mut old_value, &mut value);

@tatsuya6502
Copy link
Member Author

Since this feature is not released yet, I am setting enhancement label rather than bug.

@tatsuya6502 tatsuya6502 added the enhancement New feature or request label Aug 11, 2023
@tatsuya6502 tatsuya6502 added this to the v0.11.0 milestone Aug 11, 2023
@tatsuya6502 tatsuya6502 modified the milestones: v0.11.0, v0.12.0 Sep 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant