Redis To Go

Simple Redis Hosting


END OF LIFE NOTICE

On August 8th, 2022, we will be shutting down our platform. This decision was made after careful analysis of our business and our ability to maintain the standard of support for customers on this platform.


We recognize that this will potentially cause some challenges and we wanted to communicate this change as early as possible. To avoid any service interruptions, we recommend beginning a migration plan as soon as possible.


Thank you,

Redistogo Support

Redis To Go on Heroku

Gem Setup

The redis-rb client is the easiest way to access Redis from Ruby. Install redis-rb locally with sudo gem install redis.

Using from Rails

For Rails 2.3.3 and higher, update the config/environment.rb to include the redis gem.

config.gem 'redis' 

If using Rails 3, update the Gemfile:

gem 'redis'

Setup the Redis connection information for development in config/environments/development.rb

ENV["REDISTOGO_URL"] = 'redis://username:password@my.host:6789' 

Configure Redis in config/initializers/redis.rb

uri = URI.parse(ENV["REDISTOGO_URL"])
REDIS = Redis.new(:host => uri.host, :port => uri.port, :password => uri.password)

Test that it works in the console.

$ rails console
>> REDIS.set("foo", "bar")
"OK"
>> REDIS.get("foo")
"bar"

Using from Sinatra

In the configure block include:

configure do
  require 'redis'
  uri = URI.parse(ENV["REDISTOGO_URL"])
  REDIS = Redis.new(:host => uri.host, :port => uri.port, :password => uri.password)
end

Test that it works in the console.

$ irb -r myapp.rb
>> REDIS.set("foo", "bar")
"OK"
>> REDIS.get("foo")
"bar"

Deploying to Heroku

To use Redis To Go on Heroku, install the redistogo add-on:

$ heroku addons:add redistogo

Test that it works from the Heroku console:

$ heroku console
>> REDIS.set("answer", 42)
"OK"
>> REDIS.get("answer")
42