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

Set entry's timestamps immediately after insertion #156

Merged
merged 11 commits into from
Jun 27, 2022

Conversation

tatsuya6502
Copy link
Member

@tatsuya6502 tatsuya6502 commented Jun 25, 2022

Up to Moka v0.8.5, cache entry's last_modified and last_accessed timestamps were not set to the current time when it was inserted (when it was temporary admitted). Instead, they were set to the time when the entry was admitted. This is done by the housekeeper thread with ~0.3 second interval when cache is not receiving heavy writes.

This caused an issue #155 that invalidate_all and invalidate_entries_if methods will not invalidate entries that were inserted just before invalidate_all or invalidate_entries_if was called.

This PR fixes the issue by setting cache entry's last_modified and last_accessed timestamps to the time when it was inserted:

  • EntryInfo's timestamps will be set when it is inserted.
  • Add is_dirty flag to the EntryInfo to indicate it was just inserted but has not been processed by the housekeeper.
  • Update the unit tests for invalidate_all; remove cache.sync() after insertions.

Fixes #155

- `EntryInfo`'s timestamps are no longer optional and set when it is inserted.
- Add `is_dirty` flag to the `EntryInfo` to indicate it was just inserted but
  has not been processed by the housekeeper.
- Update the unit tests for `invalidate_all`; remove `cache.sync()` after
  insertions.
@tatsuya6502 tatsuya6502 changed the title Update entry's timestamps immediately after insertion Set entry's timestamps immediately after insertion Jun 25, 2022
@tatsuya6502 tatsuya6502 added this to the v0.8.6 milestone Jun 25, 2022
Add `AtomicInstant::new` function `atomic_time_compat` module like
we did for`atomic_time` module in a previous commit.
Add `AtomicInstant::new` function `atomic_time_compat` module like
we did for`atomic_time` module in a previous commit.
- Update the change log.
- Add doc comments to some of the fields of `EntryInfo`.
- Update internal `evict_lru_entries` and `submit_invalidation_task` methods to
  check if entry is dirty.
- Add some TODO comments about skipping dirty entries to internal `remove_expired_ao`
  and `remove_expired_wo` methods .
Fix compile errors with `KeyDate<K>::is_dirty` method.
Copy link
Member Author

@tatsuya6502 tatsuya6502 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Merging.

@tatsuya6502 tatsuya6502 merged commit 8f61b35 into master Jun 27, 2022
@tatsuya6502 tatsuya6502 deleted the update-timestamps-immediately branch June 27, 2022 12:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug in moka::future::Cache::invalidate_all? Elements not being invalidated immediatelly.
1 participant