flyerhzm / redis-sentinel

another redis automatic master/slave failover solution for ruby by using built-in redis sentinel (deprecated)
MIT License
188 stars 67 forks source link

Use with Rails.config.cache_store? #30

Closed matkam closed 10 years ago

matkam commented 10 years ago

Is it possible to use this gem with Rails.config.cache_store? I'm setting the Rails cache_store like so:

config.cache_store = :redis_store, { master_name: 'master', sentinels: [{host: 'localhost', port: 26379}], :expires_in => 1.hour }

But accessing the Rails cache gives a Redis::CannotConnectError caused by "try_next_sentinel" method. Upon further investigation, it looks like Rails.cache is a RedisStore object with an empty @options[:sentinels] array, even though its @options[:master_name] variable is set correctly.

matkam commented 10 years ago

I've tracked it back to Rails::Application::Bootstrap, which calls ActiveSupport::Cache.lookup_store(config.cache_store). "config.cache_store" comes with the blank sentinels array.

matkam commented 10 years ago

For some reason, it doesn't like a hashes inside the sentinels array, but strings inside the array come out fine...