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

Added add method to allow adding values to cache directly. #56

Draft
wants to merge 2 commits into
base: series/1.x
Choose a base branch
from

Conversation

ithinkicancode
Copy link
Contributor

Resolves #39

@@ -25,7 +25,9 @@ import java.util.concurrent.atomic.{AtomicBoolean, LongAdder}
* the same key the lookup function will only be computed once and the result
* will be returned to all fibers.
*/
sealed abstract class Cache[-Key, +Error, +Value] {
sealed abstract class Cache[-Key, +Error, Value] {
Copy link
Contributor

Choose a reason for hiding this comment

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

The loss of variance is a significant downside here. We should try to push this functionality into the Lookup function.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll rework it... Yeah, I encountered some problem with variance. Tried doing [V >: Value] but the underlying Hashmap/ConcurrentHashmap is invariant. As a compromise, I made Value invariant, hence the draft :)

Let me rework this. Thanks Adam.

Copy link

@giordanoj giordanoj Jul 21, 2023

Choose a reason for hiding this comment

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

@adamgfraser did you have any additional thoughts on how to push this into Lookup. I've been playing around with it a little without much luck. Tried adding a get function that accepts a custom/temporary lookup, but gets messy because you have to add that to the interface level as well

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Ability to add cache entries directly, bypassing the Lookup function
3 participants