Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Rake task for connecting to Redis on Heroku. Replace OPENREDIS_URL with whatever environment variable contains Redis connection string.
desc 'Connect to Redis (production)'
task :redis do
redis_uri = `heroku config:get OPENREDIS_URL`
pattern = /redis:\/\/:(\S+)@(\S+):(\d+)/
redis_uri[pattern]
command = "redis-cli -a #{$1} -h #{$2} -p #{$3}"
exec command
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment