This add-on is operated by Stovepipe Studios, Inc.
Redis 7.0, Instrumented and Scaled
RedisGreen
Last updated August 29, 2022
Table of Contents
RedisGreen is the former name of Memetria for Redis. If you’re just starting out, provision a Memetria for Redis database instead of using the RedisGreen addon. You can read find the docs for Memetria for Redis on the Heroku Dev Center.
Provisioning the Add-on
Add RedisGreen to an app via the Heroku CLI:
$ heroku addons:create redisgreen:minidev
Adding redisgreen:minidev to fancy-slinky-2001... done, v24 ($14/mo)
Your Memetria database has been built. You can find REDISGREEN_URL in your Heroku config
Created redisgreen-adjacent-38367 as REDISGREEN_URL
Use `heroku addons:docs redisgreen:minidev` to view documentation
After provisioning RedisGreen, the REDISGREEN_URL
config var is
available in the attached app’s configuration. It contains the Redis URI for
your Redis server. You can see the config var via the heroku config:get
command:
$ heroku config:get REDISGREEN_URL
redis://default:PASSWORD@HOST:PORT
For example:
$ heroku config:get REDISGREEN_URL
redis://default:gnysfn55t65g72ntd4g0a6h8ea91ca9v@smart-panda.redisgreen.net:10042
Provisioning Multiple RedisGreen Add-ons
You can attach multiple RedisGreen add-ons to your app multiple times to create separate dedicated databases for different purposes:
$ heroku addons:add redisgreen:minidev
Adding redisgreen:minidev to fancy-slinky-2001... done, v25 ($14/mo)
Your Memetria database has been built. You can find REDISGREEN_URL in your Heroku config
Created redisgreen-curved-92092 as REDISGREEN_AQUA_URL
Use `heroku addons:docs redisgreen:minidev` to view documentation
Each RedisGreen database has its own URL in your Heroku app config:
$ heroku config | grep REDISGREEN
REDISGREEN_URL: redis://default:PASSWORD@HOST:PORT
REDISGREEN_AQUA_URL: redis://default:PASSWORD@HOST:PORT
Attaching RedisGreen to Other Apps
After provisioning RedisGreen, you can attach it to other Heroku apps.
Find the addon ID with heroku addons
$ heroku addons
Add-on Plan Price State
────────────────────────────────────────────── ─────── ────────── ───────
redisgreen (redisgreen-adjacent-38367) minidev $14/mo created
└─ as REDISGREEN
redisgreen (redisgreen-curved-92092) minidev $14/mo created
└─ as REDISGREEN_AQUA
And attach the database to an app using the addon ID:
$ heroku addons:attach redisgreen-adjacent-38367
Memetria Dashboard
The Memetria dashboard provides graphs, alerts, diagnostic information, and more. Access the Memetria dashboard through your app’s Heroku Dashboard page or through the Heroku CLI:
$ heroku addons:open redisgreen
You can also consult Memetria’s own documentation at www.memetria.com/docs.
Managing Redis Versions
RedisGreen supports multiple versions. You can choose the Redis version
that is appropriate for your application or use Memetria’s recommended setting
in the Settings
panel of the Memetria dashboard.
Security patches and minor versions are automatically applied.
Custom Configuration
Many settings can be configured directly from your Memetria dashboard. If you
need custom configuration, you can click the Support
button in the
Memetria dashboard or email us at
support@memetria.com and we’ll work
with you to implement the best configuration for your particular needs.
Rotating Credentials
To rotate credentials for your RedisGreen server, click the Support
button
in the Memetria dashboard and request a credential rotation. This rotation pushes a new REDISGREEN_URL
to your application and restarts your dynos with the new credentials. Memetria’s support team confirms the rotation before disabling the old
credentials.
Local Setup
Environment Setup
After provisioning RedisGreen, you can replicate its config vars locally for development environments that require it.
Use the local
Heroku CLI
command to configure, run, and manage process types specified in your app’s
Procfile. Heroku Local reads configuration variables from a .env
file. Use heroku config
to view an app’s configuration variables in a
terminal. Use the following command to add a configuration variable to a local
.env
file:
$ heroku config:get REDISGREEN_URL -s >> .env
Your RedisGreen URL is sensitive and should not be committed to source
control. In Git exclude the .env
file with: echo .env >> .gitignore
.
For more information, see the Heroku Local article.
Language-Specific Integrations
Using Redis with Ruby
Add the redis
and connection_pool
gems to your Gemfile:
gem 'connection_pool'
gem 'redis'
Run bundle install
to install them.
For Rails apps, configure your cache store to use RedisGreen, in
config/environments/production.rb
:
config.cache_store = :redis_cache_store, {
url: ENV["REDISGREEN_URL"],
}
If you’re using Sidekiq, supply the RedisGreen URL
in a Sidekiq initializer (config/initializers/sidekiq.rb
):
Sidekiq.configure_server do |config|
config.redis = { url: ENV["REDISGREEN_URL"] }
end
Create a Client
You can create a client with:
redis = Redis.new(url: ENV["REDISGREEN_URL"])
Or access through a connection pool for use within multithreaded environments like Sidekiq and Puma:
redis = ConnectionPool.new { Redis.new(url: ENV["REDISGREEN_URL"]) }
redis.with do |client|
client.set("greeting", "hello, world!")
client.get("greeting") # => 'hello, world!'
end
Using Redis with Python
Install the redis
package:
pip install redis
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 must also update your Django session engine settings:
SESSION_ENGINE = "django.contrib.sessions.backends.cache"
SESSION_CACHE_ALIAS = "default"
Create a Client
Create your Redis connection with:
import os, redis
redis = redis.from_url(os.getenv("REDISGREEN_URL"))
Using Redis with Node.js
Install the ioredis
package using npm
:
$ npm install ioredis
You can then create your Redis connection with:
const Redis = require("ioredis");
const redis = new Redis(process.env.REDISGREEN_URL);
Using Redis with PHP
The predis
library is recommended. Add the library to your composer.json
file:
composer require predis/predis
And connect by using the REDISGREEN_URL
config var:
$redis = new Predis\Client(getenv('REDISGREEN_URL'));
Plan Management
Automatic Upgrades
Automatic Upgrades are enabled by default on all RedisGreen databases. If you reach the memory limits of your plan, Memetria automatically upgrades you to the next size and send you a notification.
If your memory usage returns within the plan limits, no action is necessary: Memetria restores your plan to the previous size without affecting your application.
If you choose to make the automatic upgrade permanent, you must change the plan size on Heroku. See Migrating Plans for more info.
If you choose not to keep the upgraded plan size, Memetria begins enforcing the limits of your Heroku plan after notifying you.
You can disable automatic upgrades at any time from the Settings
menu in the
Memetria dashboard.
Migrating Plans
When you alter the plan of your RedisGreen database, your hostname stays the same and your database stays online and available.
You can choose new plan sizes via your Heroku dashboard, or with the CLI:
$ heroku addons:upgrade redisgreen:dev
Changing redisgreen-shaped-48055 on calm-beach-06843 from redisgreen:minidev to redisgreen:dev... done, ($39/mo)
Migration to the Development plan started. Your Redis URL will remain the same.
Removing the Add-on
You can remove RedisGreen from your app via the Heroku CLI:
This action destroys all associated data and you can’t undo it! Download the most recent backup from the dashboard before removing the add-on.
You can download your latest backup from your RedisGreen database by
visiting your Memetria dashboard (heroku addons:open redisgreen
) and
navigating to the Backup list by clicking Settings
then Backups
.
After downloading your data, remove your RedisGreen addon:
$ heroku addons:destroy redisgreen
! WARNING: Destructive Action
! This command will affect the app: example-app
! To proceed, type "example-app" or re-run this command with --confirm example-app
> example-app
Removing redisgreen:minidev from example-app... done, v25 ($14/mo)
Additional Support
Use the Support
button in the Memetria dashboard or email
support@memetria.com to get help with
any aspect of your Redis server, including custom configurations.