Session heroku上的Redis会话存储
我正在尝试使用redis store作为heroku上的会话存储。它在开发中运行良好,但我无法在heroku上获得redis连接。它试图连接到127.0.0.1而不是正确的redis服务器 错误:Session heroku上的Redis会话存储,session,heroku,redis,ruby-on-rails-3.2,Session,Heroku,Redis,Ruby On Rails 3.2,我正在尝试使用redis store作为heroku上的会话存储。它在开发中运行良好,但我无法在heroku上获得redis连接。它试图连接到127.0.0.1而不是正确的redis服务器 错误: ActionView::Template::Error (Error connecting to Redis on 127.0.0.1:6379 (ECONNREFUSED)): 我已经将heroku redis配置设置为正确的服务器(实际上不用于会话存储,但已设置) session_store.r
ActionView::Template::Error (Error connecting to Redis on 127.0.0.1:6379 (ECONNREFUSED)):
我已经将heroku redis配置设置为正确的服务器(实际上不用于会话存储,但已设置)
session_store.rb
GrnAuth::Application.config.session_store :redis_store, :server => APP_CONFIG['redis_server'], key: '_grn_session'
环境.rb
# Load the rails application
require File.expand_path('../application', __FILE__)
require 'yaml'
APP_CONFIG = YAML.load_file("#{Rails.root}/config/config.yml")[Rails.env]
# Initialize the rails application
GrnAuth::Application.initialize!
config.yml
development:
redis_server: redis://localhost:6379/
test:
redis_server: redis://localhost:6379/
production:
redis_server: redis://redistogo:################################@carp.redistogo.com:9274/
当我进入heroku控制台时,我可以检查APP\u CONFIG['redis\u server']
,并将其设置为redis服务器
我还建立了一个redis连接来使用它
redis.rb
uri = URI.parse(ENV["REDISTOGO_URL"] || "redis://localhost:6379/" )
$redis = Redis.new(:host => uri.host, :port => uri.port, :password => uri.password)
当我向heroku求助时,我可以做以下事情
irb(main):001:0> $redis
=> #<Redis client v3.0.1 for redis://carp.redistogo.com:9274/0>
irb(main):001:0>$redis
=> #
任何帮助都将不胜感激。谢谢。看起来是这样的:
GrnAuth::Application.config.session_store :redis_store, :server => APP_CONFIG['redis_server'], key: '_grn_session'
应改为:
GrnAuth::Application.config.session_store :redis_store, :servers => APP_CONFIG['redis_server'], key: '_grn_session'
您还可以使用
:redis\u server
作为参数。只是不:服务器
不久前就开始工作了,你的评论是对的。我使用了redis_服务器,GrnAuth::Application.config.session_store:redis_store,:redis_server=>APP_config['redis_server'],键:''grn_session'
GrnAuth::Application.config.session_store :redis_store, :servers => APP_CONFIG['redis_server'], key: '_grn_session'