-
Notifications
You must be signed in to change notification settings - Fork 16
Add support for refresh/refresh all #39
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds support for the "refresh" and "refresh all" functionality in the LoadingCache and its tests. Key changes include:
- Adding two new methods (refresh and refreshAll) in LoadingCache.kt that delegate to the underlying Caffeine cache.
- Creating corresponding tests in AsLoadingCacheTest.kt to verify refresh behavior for single and multiple keys.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
File | Description |
---|---|
aedile-core/src/test/kotlin/com/sksamuel/aedile/core/AsLoadingCacheTest.kt | Added tests to verify refresh and refreshAll functionality. |
aedile-core/src/main/kotlin/com/sksamuel/aedile/core/LoadingCache.kt | Introduced refresh and refreshAll methods for cache refresh operations. |
fun refresh(key: K) { | ||
cache.synchronous().refresh(key) | ||
} | ||
|
||
/** | ||
* Loads a new value for each key, asynchronously. While the new value is loading the | ||
* previous value (if any) will continue to be returned by get(key) unless it is evicted. | ||
* | ||
* See full docs at [com.github.benmanes.caffeine.cache.LoadingCache.refreshAll]. | ||
*/ | ||
fun refreshAll(keys: Collection<K>) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't the new methods be suspending, calling await
and returning the value?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I don't know what I was thinking?!
2.1.1 coming out
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
... sorry to bug again, but what about the return value? :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is what happens when I do things after drinking :)
Try 2.1.2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks :-)
Closes #38