Closed PikachuEXE closed 8 years ago
oh this does not work if I have something like this:
redis://username:password@somewhere.com:port
Since it does not contain db number at the end
Now I changed to this:
# Be sure to restart your server when you modify this file.
DEFAULT_PORT = 6379
namespace = "#{Rails.application.class.parent_name.underscore}:#{Rails.env.to_s.underscore}:sessions"
uri = URI.parse(Rails.configuration.redis_url)
Rails.application.config.session_store :redis_store, {
redis_server: {
host: uri.host,
port: uri.port || DEFAULT_PORT,
password: uri.password,
namespace: namespace,
},
key: "_#{Rails.application.class.parent_name.underscore}_#{Rails.env.to_s.underscore}_sessions_",
}
I am not sure if the db number in the URL is important or not So this might not be perfect
@PikachuEXE Can you please confirm for me if this problem is still an issue or not?
I can reproduce the lack of namespace with the following code:
redis_url_without_namespace = "redis://127.0.0.1:6379"
namespace = "#{Rails.application.class.parent_name.underscore}:#{Rails.env.to_s.underscore}:sessions"
url = "#{redis_url_without_namespace}/#{namespace}"
Rails.application.config.session_store :redis_store, {
redis_server: url,
key: "_#{Rails.application.class.parent_name.underscore}_#{Rails.env.to_s.underscore}_sessions_",
}
But I am not sure if namespace can be put inside a Redis URL or not (without db number)
@PikachuEXE are you still having issues selecting the redis namespace?
I test with the following which seem to work fine:
Rails.configuration.redis_url
#=> "redis://127.0.0.1:6379/0"
namespace = "#{Rails.application.class.parent_name.underscore}:#{Rails.env.to_s.underscore}:sessions"
url = "#{Rails.configuration.redis_url}/#{namespace}"
Rails.application.config.session_store :redis_store, {
redis_server: url,
key: "_#{Rails.application.class.parent_name.underscore}_#{Rails.env.to_s.underscore}_sessions_",
}
It takes me hours to figure out how to use namespace when using this session store
Not sure if this issue belongs here or
redis-rack