Skip to content

Instantly share code, notes, and snippets.

@Alphabetus Alphabetus/redis.rb

forked from pubis/redis.rb
Last active Sep 18, 2019
What would you like to do?
Redis config and initialization for rails
require 'redis'
require 'redis/objects'
REDIS_CONFIG = YAML.load( 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::Objects.redis = $redis
#$redis_ns =[:namespace], :redis => $redis) if cnfg[:namespace]
# To clear out the db before each test
$redis.flushdb if Rails.env = "test"
host: localhost
port: 6379
db: 0
# namespace: appname_dev
db: 1
# namespace: appname_test
db: 2
host: # heroku
# namespace: appname_prod
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.