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

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

👋 Welcome to the Stackhero documentation!

Stackhero offers a ready-to-use Valkey 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 Valkey cloud hosting solution!

To configure Valkey as a cache system in Ruby on Rails, follow these steps:

  1. Install the redis gem:
bundle add redis
  1. Edit the config/environments/production.rb file and add the following configuration:
config.cache_store = :redis_cache_store, { url: ENV['VALKEY_URL'] }
  1. Define the VALKEY_URL environment variable. Use a URL in the following format, replacing <yourPassword> and <XXXXXX> with your credentials:
VALKEY_URL="rediss://default:<yourPassword>@<XXXXXX>.stackhero-network.com:<PORT_TLS>"

For more details about configuring Valkey as a cache system for Ruby on Rails, you might want to consult the official Rails documentation here.