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
      • Background Jobs in Python
      • Working with Django
    • Java
      • Working with Maven
      • Java Database Operations
      • Working with Spring Boot
      • Java Advanced Topics
    • 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 Data For 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
  • Databases & Data Management
  • Heroku Data For Redis
  • Managing Heroku Data for Redis Using the CLI

Managing Heroku Data for Redis Using the CLI

English — 日本語に切り替える

Last updated January 06, 2023

Table of Contents

  • redis:info
  • redis:cli
  • redis:credentials
  • redis:promote
  • redis:timeout
  • redis:maxmemory
  • redis:keyspace-notifications
  • redis:stats-reset

Heroku Data for Redis is integrated directly into the Heroku CLI and offers several commands for managing a Redis instance.

redis:info

To see all Redis instances provisioned by your application and to identify the characteristics of each, use the heroku redis:info command.

$ heroku redis:info
=== maturing-deeply-2628 (REDIS_URL)
Plan               Premium 0
Status             Available
Created            2015-03-26 23:40 UTC
Timeout            60
Maxmemory          volatile-lru
Maintenance window Mondays 22:30 to Tuesdays 02:30 UTC
Persistence        AOF

=== maturing-calmly-4191 (HEROKU_REDIS_AMBER_URL)
Plan               Premium 1
Status             Available
Created            2015-03-20 23:40 UTC
Timeout            0
Maxmemory          noeviction
Maintenance window Mondays 22:30 to Tuesdays 02:30 UTC
Persistence        AOF

redis:cli

To establish a Redis CLI session with your remote Redis instance, use heroku redis:cli. If you don’t specify an instance, then the instance located at REDIS_URL is used by default.

$ heroku redis:cli -a myapp -c myapp
Connecting to maturing-deeply-2628 (REDIS_URL):
ec2-54-221-206-137.compute-1.amazonaws.com:6379> PING
PONG
ec2-54-221-206-137.compute-1.amazonaws.com:6379>

If there are multiple instances, specify the instance to connect to. As a shorthand, you can specify the HEROKU_REDIS_<color> config var name as the first argument to the command, or the resource name maturing-deeply-2628.

$ heroku redis:cli HEROKU_REDIS_AMBER
$ heroku redis:cli maturing-deeply-2628

redis:credentials

Heroku Data for Redis provides convenient access to the credentials and location of your instance. This makes it easier to use a GUI to access your instance.

The instance name argument must be provided with the redis:credentials command. Use REDIS_URL for your primary data store.

$ heroku redis:credentials REDIS_URL
redis://h:pfl0cfuvr58fhsduesr9kau765k@ec2-54-221-206-137.compute-1.amazonaws.com:6379

It’s a good security practice to rotate the credentials for important services on a regular basis. On Heroku Data for Redis, use heroku redis:credentials --reset to rotate credentials.

$ heroku redis:credentials HEROKU_REDIS_GRAY_URL --reset

When you issue this command, new credentials are created for your instance and the related config vars on your Heroku application are updated.

All of the open connections remain open until the currently running tasks complete. This is to make sure that any background jobs or other workers running on your production environment aren’t abruptly terminated, potentially leaving the system in an inconsistent state. Any new connections opened after the credentials rotation has been run but before dynos have restarted with the new value of the config var will fail.

redis:promote

In configurations where with multiple Redis instances provisioned, it’s often necessary to promote an instance to the primary role. You can promote an instance using the heroku redis:promote command.

$ heroku redis:promote shining-surely-6441 -a myapp
Promoting shining-surely-6441 to REDIS_URL on myapp

redis:promote works by setting the value of the REDIS_URL config var (which your application uses to connect) to the newly promoted instance’s URL and restarting your app. The old primary Redis instance location is still accessible via its HEROKU_REDIS_COLOR_URL setting.

After a promotion, the demoted instance is still provisioned and incurring charges. If it’s no longer needed, remove it with heroku addons:destroy maturing-deeply-2628.

redis:timeout

To change the number of seconds Redis waits before killing idle connections, use the redis:timeout command:

$ heroku redis:timeout maturing-deeply-2628 --seconds 60
Timeout for maturing-deeply-2628 (REDIS_URL) set to 60 seconds.
Connections to the redis instance will be stopped after idling for 60 seconds.

redis:maxmemory

To change the key eviction policy used when an instance reaches its storage limit, use the redis:maxmemory command:

$ heroku redis:maxmemory maturing-deeply-2628 --policy volatile-lru
Maxmemory policy for maturing-deeply-2628 (REDIS_URL) set to volatile-lru.
volatile-lru evicts keys trying to remove the less recently used keys first, but only those that have an expiry set.

redis:keyspace-notifications

Heroku Data for Redis supports keyspace notifications. To configure this, use the redis:keyspace-notifications command:

$ heroku redis:keyspace-notifications maturing-deeply-2628 --config AKE
Keyspace notifications for maturing-deeply-2628 (REDIS_URL) set to 'AKE'.

A number of possible configurations are possible. Consult heroku help redis:keyspace-notifications for more.

redis:stats-reset

Resets the statistics on your Heroku Data for Redis instance. This article outlines the statistics that are reset:

$ heroku redis:stats-reset maturing-deeply-2628
 ▸    WARNING: Irreversible action.
 ▸    All stats covered by RESETSTAT will be reset on maturing-deeply-2628.
 ▸    To proceed, type sushi or re-run this command with --confirm sushi

> sushi
Stats reset successful.

Keep reading

  • Heroku Data For Redis

Feedback

Log in to submit feedback.

Upgrading a Heroku Data for Redis Version Understanding Heroku Data for Redis Log Statements and Common Errors

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