RedisGreen

This add-on is operated by Stovepipe Studios

Production-quality Redis servers with superior support and analytics

RedisGreen

Last Updated: 19 March 2014

Table of Contents

Creating a RedisGreen server

You can use the Heroku Toolbelt to add RedisGreen to your app:

% heroku addons:add redisgreen:basic
Adding redisgreen:basic to fancy-slinky-2001... done, v24 ($169/mo)
Basic Redis server successfully provisioned.
Use `heroku addons:docs redisgreen:basic` to view documentation

Once your RedisGreen server has been built, your app will have access to a “REDISGREEN_URL” environment variable that contains the Redis URI for your Redis server. You can also view the RedisGreen environment variable using the Heroku Toolbelt:

% heroku config | grep REDISGREEN
REDISGREEN_URL: redis://rg:gnysfn55t65g72ntd4g0a6h8ea91ca9v@smart-panda.redisgreen.net:10041

Using Redis with Ruby

Add the redis and hiredis gems to your Gemfile and run bundle install to install them:

gem 'redis'
gem 'hiredis'

For Rails apps, create an initializer at config/initializers/redis.rb to create a global Redis connection when your app loads:

$redis = Redis.new(url: ENV["REDISGREEN_URL"], driver: :hiredis)

For all non-Rails projects, you can use the above code wherever it makes the most sense. For instance, in Sinatra apps, you would put the above code in the “configure” block:

require 'redis'

configure :production do
  uri = URI.parse(ENV["REDISGREEN_URL"])
  $redis = Redis.new(url: ENV["REDISGREEN_URL"], driver: :hiredis)
end

configure :development, :test do
  $redis = Redis.new
end

Using Redis with Python

Install the “redis” package:

% pip install redis

And create your Redis connection with:

import os, redis

redis = redis.from_url(os.getenv("REDISGREEN_URL"))

To use Redis as a cache backend for your Django app with django-redis-cache:

from urlparse import urlparse

redisgreen = urlparse(os.getenv("REDISGREEN_URL"))

CACHES = {
    'default': {
        'BACKEND': 'redis_cache.RedisCache',
        'LOCATION': '%s:%i' % (redisgreen.hostname, redisgreen.port),
        'OPTIONS': {
            'DB': 1,
            'PASSWORD': redisgreen.password,
            'PARSER_CLASS': 'redis.connection.HiredisParser'
        }
    }
}

Using Redis with Node.js

Install the “redis” package using npm:

% npm install redis

However, we strongly recommend using “redis” with the “hiredis” driver:

% npm install hiredis redis

And then run npm install to install the package locally. You can then create your Redis connection with:

var redis = require("redis");

if (process.env.REDISGREEN_URL) {
  var redisgreen = require("url").parse(process.env.REDISGREEN_URL);
  var client = redis.createClient(redisgreen.port, redisgreen.hostname);
  client.auth(redisgreen.auth.split(":")[1]);
} else {
  var client = redis.createClient();
}

RedisGreen dashboard

The RedisGreen dashboard has a wide array of graphs, alerts, diagnostic information, and other features that make analyzing the health and performance of your server easy. You can access the RedisGreen dashboard through your app’s Heroku page or through the Heroku Toolbelt:

% heroku addons:open redisgreen

Removing RedisGreen

RedisGreen can be removed from your app via the Heroku Toolbelt:

After you remove RedisGreen from your app, the Redis server will be taken down and deleted. We recommend that you download the most recent backup from the dashboard before removing RedisGreen.
% heroku addons:remove redisgreen:basic

 !    WARNING: Destructive Action
 !    This command will affect the app: fancy-slinky-2001
 !    To proceed, type "fancy-slinky-2001" or re-run this command with --confirm fancy-slinky-2001

> fancy-slinky-2001
Removing redisgreen:basic from fancy-slinky-2001... done, v25 ($169/mo)

Additional Support

Use the “Support” button in the RedisGreen dashboard or email us at support@redisgreen.net to get help with any aspect of your RedisGreen server, including custom configurations.