-
-
Save sergii/2e270e1d875be3b7aced to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#config/initializers/redis.rb | |
require 'redis' | |
require 'redis/objects' | |
REDIS_CONFIG = YAML.load( File.open( Rails.root.join("config/redis.yml") ) ).symbolize_keys | |
dflt = REDIS_CONFIG[:default].symbolize_keys | |
cnfg = dflt.merge(REDIS_CONFIG[Rails.env.to_sym].symbolize_keys) if REDIS_CONFIG[Rails.env.to_sym] | |
$redis = Redis.new(cnfg) | |
Redis::Objects.redis = $redis | |
#$redis_ns = Redis::Namespace.new(cnfg[:namespace], :redis => $redis) if cnfg[:namespace] | |
# To clear out the db before each test | |
$redis.flushdb if Rails.env = "test" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#config/redis.yml | |
default: | |
host: localhost | |
port: 6379 | |
development: | |
db: 0 | |
# namespace: appname_dev | |
test: | |
db: 1 | |
# namespace: appname_test | |
production: | |
db: 2 | |
host: 192.168.1.100 | |
# namespace: appname_prod |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Remember to add 'redis-namespace' to your Gemfile if your using that version. # Yes?