We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 32fb8c5 commit 7b26479Copy full SHA for 7b26479
config/initializers/redis.rb
@@ -1,3 +1,5 @@
1
# config/initializers/redis.rb
2
+redis_config = YAML.load_file(Rails.root + 'config/redis.yml')[Rails.env]
3
+$redis = Redis::Namespace.new(redis_config['namespace'], redis: Redis.new(host: redis_config['host'], port: redis_config['port']))
4
+
5
-$redis = Redis::Namespace.new("tutorial_post", :redis => Redis.new(:host => 'redis', :port => 6379))
config/redis.yml
@@ -0,0 +1,16 @@
+#config/redis.yml
+default: &default
+ host: redis
+ port: 6379
+ namespace: tutorial_post
6
+development:
7
+ <<: *default
8
+ db: 0
9
+test:
10
11
+ db: 1
12
+production:
13
14
+ db: 2
15
+ host: 192.168.1.100
16
0 commit comments