sorentwo / readthis

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

Store values without serializer prefix #36

Closed espen closed 8 years ago

espen commented 8 years ago

Perhaps this is just me nitpicking but it would be nice to store and retrieve values without any prefix. Any thoughts of making the serializer prefix optional? I feel like it should be an option to include it and not be there by default. It seems like Marshal is most commonly used by other libraries so it would be nice to switch to/from Readthis without prefixes in the values, and explicitly introduce other serializer and a prefix. Or am I missing some benefit of this current behaviour?

sorentwo commented 8 years ago

As far as I know Marshal is used by all other cache libraries including Dalli, MemoryStore, and possibly RedisActivesupport (though I haven't looked in well over a year). The serializer prefix is critical to how multiple readthis instances work, and allows everything to be consistent. If you're trying to migrate data or inspect raw values you can always use an instance of Readthis::Entity to load values that have been dumped.

espen commented 8 years ago

So it's important for multiple readthis instances (connections?), and not for migrating or using multiple serializers in one app (my assumption)?

sorentwo commented 8 years ago

Sorry, I wasn't clear. It's important in both of those situations. It can be configured on a per instance basis, but also used per entity. For example, you can have Marshal as the default and use Oj for API data.

espen commented 8 years ago

Sure, I understand the user case for it. However my first assumption of this is that it should be something explicit. If someone requires Marshal and Oj then multiple serializers could be enabled and the prefix is added. Otherwise just use Marshal without prefix?

But to be honest I don't really have a user case for dropping the prefix other than I don't want a prefix in my value :) Was just a bit surprised to see it when getting values directly from Redis.