You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As of moka v0.12.0-beta.2, an internal method do_insert_with_hash gets the ts (the base Instant, or the time that upsert is about to be performed at) before acquiring the key-level lock for notifying to the eviction listener. This could make the base instant much earlier than the actual time that the entry was upserted at, because it can take some time until the lock becomes available.
Therefore, we should change it to get the base instant after acquiring the lock.
Later, the base instant is passed to an Expiry method as the current_time, and when the expiry method returns, it is used to calculate the expiration time from the returned expiry duration. (expires_at = current_time + returned_duration). The base instant is also used by the time-to-live and time-to-idle that can be set at the cache creation time.
tatsuya6502
changed the title
An internal do_insert_with_hash gets the current Instant too early when eviction listener is enabled
An internal do_insert_with_hash method gets the current Instant too early when eviction listener is enabled
Sep 7, 2023
Relates to:
As of moka v0.12.0-beta.2, an internal method
do_insert_with_hash
gets thets
(the baseInstant
, or the time that upsert is about to be performed at) before acquiring the key-level lock for notifying to the eviction listener. This could make the base instant much earlier than the actual time that the entry was upserted at, because it can take some time until the lock becomes available.Therefore, we should change it to get the base instant after acquiring the lock.
Later, the base instant is passed to an
Expiry
method as thecurrent_time
, and when the expiry method returns, it is used to calculate the expiration time from the returned expiry duration. (expires_at = current_time + returned_duration
). The base instant is also used by the time-to-live and time-to-idle that can be set at the cache creation time.moka/src/sync_base/base_cache.rs
Lines 483 to 492 in a03488b
moka/src/future/base_cache.rs
Lines 477 to 490 in a03488b
Action Items
The text was updated successfully, but these errors were encountered: