Skip to content

Instantly share code, notes, and snippets.

@DevL
Created December 12, 2012 12:59
Show Gist options
  • Save DevL/4267523 to your computer and use it in GitHub Desktop.
Save DevL/4267523 to your computer and use it in GitHub Desktop.
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