Skip Navigation
Show nav
Heroku Dev Center
  • Get Started
  • Documentation
  • Changelog
  • Search
  • Get Started
    • Node.js
    • Ruby on Rails
    • Ruby
    • Python
    • Java
    • PHP
    • Go
    • Scala
    • Clojure
  • Documentation
  • Changelog
  • More
    Additional Resources
    • Home
    • Elements
    • Products
    • Pricing
    • Careers
    • Help
    • Status
    • Events
    • Podcasts
    • Compliance Center
    Heroku Blog

    Heroku Blog

    Find out what's new with Heroku on our blog.

    Visit Blog
  • Log inorSign up
View categories

Categories

  • Heroku Architecture
    • Dynos (app containers)
    • Stacks (operating system images)
    • Networking & DNS
    • Platform Policies
    • Platform Principles
  • Command Line
  • Deployment
    • Deploying with Git
    • Deploying with Docker
    • Deployment Integrations
  • Continuous Delivery
    • Continuous Integration
  • Language Support
    • Node.js
    • Ruby
      • Working with Bundler
      • Rails Support
    • Python
      • Working with Django
      • Background Jobs in Python
    • Java
      • Working with Maven
      • Java Database Operations
      • Working with the Play Framework
      • Java Advanced Topics
      • Working with Spring Boot
    • PHP
    • Go
      • Go Dependency Management
    • Scala
    • Clojure
  • Databases & Data Management
    • Heroku Postgres
      • Postgres Basics
      • Postgres Getting Started
      • Postgres Performance
      • Postgres Data Transfer & Preservation
      • Postgres Availability
      • Postgres Special Topics
    • Heroku Redis
    • Apache Kafka on Heroku
    • Other Data Stores
  • Monitoring & Metrics
    • Logging
  • App Performance
  • Add-ons
    • All Add-ons
  • Collaboration
  • Security
    • App Security
    • Identities & Authentication
    • Compliance
  • Heroku Enterprise
    • Private Spaces
      • Infrastructure Networking
    • Enterprise Accounts
    • Enterprise Teams
    • Heroku Connect (Salesforce sync)
      • Heroku Connect Administration
      • Heroku Connect Reference
      • Heroku Connect Troubleshooting
    • Single Sign-on (SSO)
  • Patterns & Best Practices
  • Extending Heroku
    • Platform API
    • App Webhooks
    • Heroku Labs
    • Building Add-ons
      • Add-on Development Tasks
      • Add-on APIs
      • Add-on Guidelines & Requirements
    • Building CLI Plugins
    • Developing Buildpacks
    • Dev Center
  • Accounts & Billing
  • Troubleshooting & Support
  • Integrating with Salesforce
  • Add-ons
  • All Add-ons
  • RedisGreen
RedisGreen

This add-on is operated by Stovepipe Studios

Redis 7.0, Instrumented and Scaled

RedisGreen

Last updated June 08, 2022

Table of Contents

  • Creating a RedisGreen server
  • RedisGreen Dashboard
  • Using Redis with Ruby
  • Using Redis with Python
  • Using Redis with Node.js
  • Using Redis with PHP
  • Custom Configuration
  • Rotating Credentials
  • Removing RedisGreen
  • Additional Support

Creating a RedisGreen server

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

$ heroku addons:create 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 CLI:

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

RedisGreen Dashboard

The RedisGreen dashboard provides graphs, alerts, diagnostic information, and more. Access the RedisGreen dashboard through your app’s Heroku Dashboard page or through the Heroku CLI:

$ heroku addons:open redisgreen

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 example, 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:

CACHES = {
    "default": {
        "BACKEND": "django_redis.cache.RedisCache",
        "LOCATION": os.getenv("REDISGREEN_URL"),
        "OPTIONS": {
            "CLIENT_CLASS": "django_redis.client.DefaultClient",
        }
    }
}

To use RedisGreen as your session store, you’ll also need to update your Django session engine settings:

SESSION_ENGINE = "django.contrib.sessions.backends.cache"
SESSION_CACHE_ALIAS = "default"

Using Redis with Node.js

Install the “redis” package using npm:

$ npm install redis

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

var redis = require("redis");
var client = redis.createClient(process.env.REDISGREEN_URL);

Using Redis with PHP

We recommend the predis library. Add the library to your composer.json file:

"require": {
  ...
  "predis/predis": "1.0.3",
  ...
}

And connect by using the REDISGREEN_URL environment variable:

$redis = new Predis\Client(getenv('REDISGREEN_URL'));

Custom Configuration

If you need any configuration, just hit the “Support” button in the RedisGreen dashboard or email us at support@redisgreen.net and we’ll work with you to implement the best configuration for your particular needs.

Rotating Credentials

Rotating credentials with RedisGreen is simple, just hit the “Support” link in the RedisGreen dashboard and request a credential rotation. Depending on your requirements, RedisGreen can provide a hot standby database with new credentials which you can migrate to on your own, or RedisGreen can push a new REDIS_URL variable to your application, restarting your dynos with the new credentials.

Removing RedisGreen

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

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:destroy redisgreen
  !    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.

Keep reading

  • All Add-ons

Feedback

Log in to submit feedback.

Ziggeo RedisMonitor

Information & Support

  • Getting Started
  • Documentation
  • Changelog
  • Compliance Center
  • Training & Education
  • Blog
  • Podcasts
  • Support Channels
  • Status

Language Reference

  • Node.js
  • Ruby
  • Java
  • PHP
  • Python
  • Go
  • Scala
  • Clojure

Other Resources

  • Careers
  • Elements
  • Products
  • Pricing

Subscribe to our monthly newsletter

Your email address:

  • RSS
    • Dev Center Articles
    • Dev Center Changelog
    • Heroku Blog
    • Heroku News Blog
    • Heroku Engineering Blog
  • Heroku Podcasts
  • Twitter
    • Dev Center Articles
    • Dev Center Changelog
    • Heroku
    • Heroku Status
  • Facebook
  • Instagram
  • Github
  • LinkedIn
  • YouTube
Heroku is acompany

 © Salesforce.com

  • heroku.com
  • Terms of Service
  • Privacy
  • Cookies
  • Cookie Preferences