Created
September 23, 2014 10:48
-
-
Save andywenk/409650ae4dd3a33f3863 to your computer and use it in GitHub Desktop.
redis configuration for redis-sentinel and redis-session-store
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
######### redis configuration ######### | |
### redis sentinel und sidekiq | |
# https://github.com/flyerhzm/redis-sentinel | |
# http://tom.meinlschmidt.org/2013/12/20/redis-sentinel-with-ruby-on-rails/ | |
sentinels = { | |
development: | |
[ | |
{ host: "127.0.0.1", port: 6379 } | |
], | |
preview: | |
[ | |
{ host: "x.x.x.41", port: 26379 }, | |
{ host: "x.x.x.41", port: 26380 }, | |
{ host: "x.x.x.30", port: 26379} | |
] | |
} | |
redis_connection = proc { | |
Redis.current = Redis.new(master_name: "mymaster", sentinels: sentinels[Rails.env], db: APP_CONFIG[:redis][:db]) | |
} | |
redis = ConnectionPool.new(size: 10, &redis_connection) | |
Sidekiq.configure_server do |config| | |
config.redis = redis | |
end | |
Sidekiq.configure_client do |config| | |
config.redis = redis | |
end | |
### redis session store | |
# https://github.com/roidrage/redis-session-store | |
Ace::Application.config.session_store :redis_session_store, { | |
key: APP_CONFIG[:session][:redis][:key], | |
serializer: APP_CONFIG[:session][:redis][:serializer].to_sym, #hybrid | |
on_redis_down: -> (*a) { logger.error("Redis down! #{a.inspect}") }, #fix me! | |
on_session_load_error: -> (*a) { logger.error("Redis Session load error! #{a.inspect}") }, #fix me! | |
redis: { | |
db: APP_CONFIG[:session][:redis][:db], | |
expire_after: "#{APP_CONFIG[:session][:redis][:expire_after]}".to_i.minutes, # 120.minutes | |
key_prefix: APP_CONFIG[:session][:redis][:key_prefix], # 'ace:' | |
host: APP_CONFIG[:session][:redis][:host], # '127.0.0.1' | |
port: APP_CONFIG[:session][:redis][:port], # 6379 | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment