How to prevent storing nil value in rails cache?
caching, memcached, ruby-on-rails, ruby-on-rails-3
Solution
Update:
From rails 6.0.0, you can supply the `skip_nil: true` option while calling `Rails.cache.fetch`
Here
Thanks Rick Suggs for pointing this out.
Problem
I am using redis-store for caching in my application,I don't want to fetch the key and value if the value returns nil. ``` Rails.cache.fetch{"user_by_comment_id:#{params['comment_id']}"} do User.find_by_comment_id(params['comment_id']) end ``` if it return the nil for the key "user_by_comment_id:#{params['comment_id']}",I don't want to store the key in my cache.Help me to solve this.