-
Notifications
You must be signed in to change notification settings - Fork 120
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
Refs #35: Custom generic serialisation via type class #86
Conversation
- Add Codec typeclass to allow adhoc customisation of serialisation/deserialisation - Add some default Codecs for standard primitives w/ tests - Add a Java-basd object serialiser w/ test - Modify various existing methods, macros, and tests to make this work Misc: - Bump PGP plugin version
Sorry for the slow review. I just spent ages writing a huge, detailed comment but it got deleted. Let's see if I can summon the willpower to write it all out again. The sacrifices we make for FOSS... I agree that a typeclass is a good way to implement custom serialisation. I've experimented with it in the past, but never quite got around to implementing it properly. This PR looks like a great start. Just a couple of general comments before I go through the code and make a few OCD-driven requests for changes. CompatibilityChanging the serialisation format is a big breaking change for Memcached and Redis users. After upgrading ScalaCache their cache will be effectively cold and their logs will probably start filling up with warnings about deserialisation failures. In one of my previous experiments with custom serialisation, I tried implementing a I think a more pragmatic solution would be to add a boolean flag to CompressionSpymemcached's default transcoder automatically gzips anything over 16KB. Might be nice to do that in ScalaCache as well, at least as an option. But it does complicate things, as you then need to write a header containing a compression flag. Import taxI'd like to keep imports to a minimum. Ideally just writing |
@@ -1,5 +1,6 @@ | |||
package scalacache.caffeine | |||
|
|||
import scalacache.serdes.Codec |
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.
Please can we make the package scalacache.serialization
?
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.
Cool done.
😢 I hate it when that happens. Thanks for rewriting your feedback; I know it isn't easy.
Good point; I've added a
I think that is a great idea. Would it be ok with you if that were to be added on in another PR ? Since we would be compressing and decompressing bytes, it seems reasonable to treat compression as a separate concern.
I hear you on the wanting to lower the amount of things that people need to import, but Mixing in Also, when using generic typeclasses (whether it's deriving them or bringing things in scope that derive them), I think people are familiar with having to do an additional import; Play, Argonaut, Circe etc have somewhat established this pattern. |
- Add a `useLegacySerialization` param to Memcached and Redis-related caches that activates old behaviour - Add explanation of Codec and Legacy Serialization option to readme and Changelog - Add tests for legacy codec support
c855f66
to
ed20a0e
Compare
CompressionYep, let's add it in another PR. Could even be a separate codec implementation. Import taxI think Java serialisation is a sensible default, even if it is slow. It's good enough for a lot of use cases (and hasn't put many people off using ScalaCache until now). Also, low barrier to entry is a high priority for me - a lot of people don't want to care how their stuff is being serialised, they just want to cache stuff as easily as possible. And don't forget about people using Guava/Caffeine/Ehcache/Lru. They would have to import a serialisation codec that they won't even use, which is both annoying and confusing. |
Ok got it. I think your reasoning is sound. Done in a424e52 |
Fix implicit not found message
a424e52
to
6963d8d
Compare
|
||
New features: | ||
|
||
* [#86](https://github.com/cb372/scalacache/pull/86) adds support for custom serialisation. Thanks to @lloydmeta |
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.
Haha, thanking yourself in the changelog. Nice :)
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.
That is some deep existential stuff right there.
Or just blind copy pasting of existing stuff. 😆
Just a prototype of what I mentioned on the issue, to serve as a point of discussion and garner feedback.
Goals:
Codec
(conversely, this project can have projects that provide bindings for commonly used formats)Changes:
Misc: