Redis®*: Using Redis with Ruby and Ruby on Rails

This documentation is part of the Getting started guide. You can view the complete guide here: Quick guide to getting started with Redis.

👋 Welcome to the Stackhero documentation!

Stackhero offers a ready-to-use Redis cloud solution that provides a host of benefits, including:

  • Redis Commander web UI included.
  • Unlimited message size and transfers.
  • Effortless updates with just a click.
  • Optimal performance and robust security powered by a private and dedicated VM.

Save time and simplify your life: it only takes 5 minutes to try Stackhero's Redis cloud hosting solution!

To get started, you can install the redis gem with:

bundle add redis

Next, you can open config/environments/production.rb and add the following line:

config.cache_store = :redis_cache_store, { url: ENV["REDIS_URL"] }

Then you can define the REDIS_URL environment variable. Here is a template you can adapt with your own details:

REDIS_URL="rediss://default:<yourPassword>@<XXXXXX>.stackhero-network.com:<PORT_TLS>"

By default, caching is enabled only in the production environment. If you would like to test caching during development, you can also update config/environments/development.rb. Add the same configuration shown above and include config.action_controller.perform_caching = true to enable caching. One simple way to confirm that caching is working is to start a Rails console with bin/rails console and try Rails.cache.write("foo", "bar").

For more details about using Redis as a cache store in Ruby on Rails, you can check the official Rails documentation.

Sidekiq automatically uses the Redis server defined in the REDIS_URL environment variable.

You can set REDIS_URL with your own connection details like this:

REDIS_URL="rediss://default:<yourPassword>@<XXXXXX>.stackhero-network.com:<PORT_TLS>"

For more details about using Sidekiq with Redis, you can refer to the official Sidekiq documentation.

Like Sidekiq, Resque uses the Redis server defined in the REDIS_URL environment variable.

You can set REDIS_URL with your own details like this:

REDIS_URL="rediss://default:<yourPassword>@<XXXXXX>.stackhero-network.com:<PORT_TLS>"

For more information about using Resque with Redis, you can visit the official Resque documentation.