Deploy Redis on Heroku in just 2 minutes

Before moving on to our topic of deploying Redis on Heroku, i would like to give a brief overview what redis is actually !

What is Redis ?

Redis is a :

  • In memory key-value storage
  • Support multiple datatypes (strings, hashes, lists, sets, sorted sets, bitmaps, and hyperloglogs)
  • It provides an ability to store cache data into physical storage (if needed).
  • Support pub-sub model
  • Redis cache provides replication for high availability (master/slave)

Redis has unique abilities like ultra-fast lua-scripts. Its execution time equals to C commands execution. This also brings atomicity for sophisticated Redis data manipulation required for work many advanced objects like Locks and Semaphores.

Is Redis just a Cache ?

No, Redis is much more than a cache.

Like a Cache, Redis stores key value pairs. But unlike a cache, Redis lets you operate on the values. There are 5 data types in Redis – Strings, Sets, Hash, Lists and Sorted Sets. Each data type exposes various operations.

The best way to understand Redis is to model an application without thinking about how you are going to store it in a database.

How to run Redis on Heroku ?

Redis on Heroku

To run redis on heroku we can achieve it using an heroku add on – Redis to go.

  1. Create a new Redis instance with redis to go add-on.
    heroku addons:create heroku-redis:hobby-dev -a sushi
    
  2.  To check the state of progress , you can type following command
    heroku addons:info

    State “creating” means that it is still provisioning and not yet ready. Once Heroku Redis has been created, the new release will be created and the application will restart.

  3. REDIS_URL config var will be made available in the app configuration and will contain the URL used to access the newly provisioned Heroku Redis instance. This can be confirmed using the heroku config command.
    heroku config | grep REDIS

    Thats it. By this time your dB instance must be up and running.

For other options and configurations such as :

  • Establish the primary instance

  • Promoting an instance

  • Sharing Heroku Redis between applications

  • Version support and legacy infrastructure , kindly visit the official Herko -redis documentation .

1 thought on “Deploy Redis on Heroku in just 2 minutes”

Leave a Comment