Ruby: Configuring Redis as a cache system for Ruby on Rails

This documentation is part of the Redis guide. View the full guide here: How to connect Ruby with Redis.

👋 Welcome to the Stackhero documentation!

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

  • Deploy your application in seconds with a simple git push.
  • Use your own domain name and benefit from the automatic configuration of HTTPS certificates for enhanced security.
  • Enjoy peace of mind with automatic backups, one-click updates, and straightforward, transparent, and predictable pricing.
  • Get optimal performance and robust security thanks to a private and dedicated VM.

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

To get started, you can install the redis gem:

bundle add redis

Next, you can update the config/environments/production.rb file with this line:

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

After that, you can define the REDIS_URL environment variable. This example shows the format to use. Just replace <yourPassword> and <XXXXXX> with your own values:

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

If you would like more details about using Redis as a cache system in Ruby on Rails, you can check the official Rails documentation.