Saturday, September 5, 2015

Connecting to redis on heroku with golang

I have an app on heroku using the redis-addon provided by heroku ("Redis Heroku"). To connect to this instance using go-redis, I have found this to be a working solution:
  • The redis url is provided as an environment variable, REDIS_URL
  • To use redis from golang, I use redis-go.  I install this library by typing "go get github.com/gopkg.in/redis.v3"
  • Parse the url and extract the user before connecting(unless, you might end up with the error "dial tcp: too many colons in address redis://...")

No comments:

Post a Comment