sorentwo / readthis

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

Can readthis use hashes instead of strings? #64

Closed blarralde closed 6 years ago

blarralde commented 6 years ago

Hey there,

Is there a way to configure readthis to use hashes instead of strings as described here? https://redis.io/topics/memory-optimization#using-hashes-to-abstract-a-very-memory-efficient-plain-key-value-store-on-top-of-redis

Thanks, Ben

sorentwo commented 6 years ago

No, there isn't a way to do this directly with readthis. You can access the redis pool directly using the with method on Rails.cache, but this is a very application specific way of doing things.

I've written about this a fair bit in the past:

https://sorentwo.com/2015/08/10/efficient-redis-caching-through-hashing.html https://sorentwo.com/2015/08/17/reconstructing-payloads-with-lua.html

Ultimately cache expiration and nested associations proved difficult to generalize. You may be interested in Knuckles for performant caching with arbitrary associations and distinct expiration.