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
I have a use case where my cache expires entries hours after being written. I would like to lazily refresh these values to prevent staleness, i.e. if I retrieve an entry older than a few minutes, Moka will yield the stale value but also kick off a background process to compute the latest value.
The desired behavior would be adjacent to Guava's LoadingCache refreshAfterWrite functionality:
refreshAfterWrite will make a key eligible for refresh after the specified duration, but a refresh will only be actually initiated when the entry is queried.
Callers would need to provide (1) a function that Moka executes in the background to compute the latest cache value and (2) a parameter to define a staleness threshold after which a refresh should be performed.
It's easy to write a small wrapper that implements this behavior, but perhaps it would be more widely beneficial to include support for this directly in Moka. Curious if this could be considered/added to the roadmap, thanks!
The text was updated successfully, but these errors were encountered:
Hey team!
I have a use case where my cache expires entries hours after being written. I would like to lazily refresh these values to prevent staleness, i.e. if I retrieve an entry older than a few minutes, Moka will yield the stale value but also kick off a background process to compute the latest value.
The desired behavior would be adjacent to Guava's LoadingCache refreshAfterWrite functionality:
Callers would need to provide (1) a function that Moka executes in the background to compute the latest cache value and (2) a parameter to define a staleness threshold after which a refresh should be performed.
It's easy to write a small wrapper that implements this behavior, but perhaps it would be more widely beneficial to include support for this directly in Moka. Curious if this could be considered/added to the roadmap, thanks!
The text was updated successfully, but these errors were encountered: