Skip to content

Commit 7b26479

Browse files
committed
Added redis.yml
1 parent 32fb8c5 commit 7b26479

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

config/initializers/redis.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
# 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+
25

3-
$redis = Redis::Namespace.new("tutorial_post", :redis => Redis.new(:host => 'redis', :port => 6379))

config/redis.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#config/redis.yml
2+
default: &default
3+
host: redis
4+
port: 6379
5+
namespace: tutorial_post
6+
development:
7+
<<: *default
8+
db: 0
9+
test:
10+
<<: *default
11+
db: 1
12+
production:
13+
<<: *default
14+
db: 2
15+
host: 192.168.1.100
16+
namespace: tutorial_post

0 commit comments

Comments
 (0)