简体   繁体   English

如何设置Redis连接

[英]How to setup redis connection

in order to use RedisToGo on development, I need to set the environment variable as follows: ENV["REDISTOGO_URL"] = 'redis://username:password@my.host:6389' 为了在开发中使用RedisToGo,我需要如下设置环境变量:ENV [“ REDISTOGO_URL”] ='redis:// username:password@my.host:6389'

How can I create a redis connection with the username, password and my.host setting, assuming I already have redis-server installed? 假设我已经安装了redis-server,如何使用用户名,密码和my.host设置创建Redis连接? I think there's a commandline command I have used to achieve this before but I can't seem to remember it now and I can't find any information on this online. 我认为我以前曾经使用过一个命令行命令来实现此目的,但现在看来我已经不记得了,也无法在线上找到任何信息。 Suggestions? 建议?

My setup is similar and uses the following: 我的设置与此类似,并使用以下内容:

# config/initializers/redis.rb
uri = URI.parse(ENV["REDISTOGO_URL"])
REDIS = Redis.new(host: uri.host, port: uri.port, password: uri.password)

development & test environments: 开发和测试环境:

ENV['REDISTOGO_URL'] = 'redis:://@localhost:6379'

And then you don't need to set anything for production as long as you have the gem and RedisToGo installed on your Heroku instance. 然后,只要在Heroku实例上安装了gem和RedisToGo,就不需要为生产设置任何东西。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM