sorentwo / readthis

:newspaper: Pooled active support compliant caching with redis
MIT License
504 stars 40 forks source link

Serializers should be configurable (in initializer?) #18

Closed fabn closed 9 years ago

fabn commented 9 years ago

As you moved to the binary format for flags and since the hash is frozen, no further serializers can be added anymore, e.g. Oj

The solution would be to allow user to add custom serializers (e.g. in a rails initializer file), something like

Readthis.add_serializer(Oj)

Since having a frozen hash for serializer is a very good thing once the app is configured I'd also add a method to lock them, like

Readthis.freeze_serializers!

The drawback is that user needs to call that method manually, in Rails code you might introduce a railtie to freeze that hash after app initialization.

Also if you want to have some more slots you can refactor the binary flag to use 4 bytes for serializer I used only 3 bits because no user will use more than 3 or 4 of them, but you still have 4 bits available for whatever you need. Otherwise you can shift the compressed flag to the left side using 0x80 as value for COMPRESSED_FLAG in this way the 4 unused bits will remain in the center part of the byte.

Sorry to bother you with all these requests, but you're building a very good library and I'd like to use it in my projects.

sorentwo commented 9 years ago

I had very similar thoughts. I don't plan on releasing a new build until the ability to configure serializers has landed.

sorentwo commented 9 years ago

It is so! Closed with #21