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

Support polymorphic keys #565

Merged

Conversation

ronnnnnnnnnnnnn
Copy link
Contributor

With regard to standardizing the key serialization by making it part of AbstractCache - didn't think it was really necessary so preferred to keep it cleaner and more consistent with value serialization which is left up to the various implementations. I did make some changes to the codec library to allow for simple usage by implementations also for keys, and added such usage to the Redis implementation.
However, If you think it might still be better to standardize it some more, maybe I can add another layer for that inheriting from AbstractCache or something.
Anyway, I hope this is alright. Let me know what you think.

@ronnnnnnnnnnnnn ronnnnnnnnnnnnn changed the title Feature/355 support polymorphic keys Support polymorphic keys Aug 13, 2021
@ronnnnnnnnnnnnn
Copy link
Contributor Author

Merged the latest from master (including #517 and #561) and resolved the conflicts to make this compatible with the recent changes.

@@ -65,17 +60,17 @@ object CaffeineCache {

/** Create a new Caffeine cache.
*/
def apply[F[_]: Sync: Clock, V](implicit config: CacheConfig): F[CaffeineCache[F, V]] =
Sync[F].delay(Caffeine.newBuilder().build[String, Entry[V]]()).map(apply(_))
def apply[F[_]: Sync: Clock, K <: AnyRef, V]: F[CaffeineCache[F, K, V]] =
Copy link
Collaborator

Choose a reason for hiding this comment

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

It looks like Caffeine requires the K and V to both extend Object (from Java). This wasn't a problem in the past because we were always using String keys. Weirdly, this also only seems to be an issue on Scala 2.12 as it compiles fine for 2.13 and 3. I had to add <: AnyRef just for 2.12, but I am not really sure of an alternative. @kubukoz Do you happen to have any thoughts on this?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Added an issue #603 to discuss this further. Merging this PR so we can continue on with other things in the meantime.

@lewisjkl lewisjkl merged commit cf0036f into cb372:master Nov 9, 2021
@lewisjkl
Copy link
Collaborator

lewisjkl commented Nov 9, 2021

Thanks again @ronnnnnnnnnnnnn for putting this together and sorry it took so long to get around to merging.

@ronnnnnnnnnnnnn ronnnnnnnnnnnnn deleted the feature/355-support-polymorphic-keys branch November 12, 2021 16:07
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.

2 participants