Ruby: Configuring Redis as a cache system for Ruby on Rails
This documentation is part of the Redis guide. View the full guide here: Connect Ruby and Ruby on Rails with Redis for fast caching and background jobs.
👋 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, dedicated infrastructure.
Save time and simplify your life: it only takes 5 minutes to try Stackhero's Ruby cloud hosting solution!
To integrate Redis caching, you can add the redis gem to your project:
bundle add redis
Then, update your config/environments/production.rb file:
config.cache_store = :redis_cache_store, { url: ENV["REDIS_URL"] }
Set the REDIS_URL environment variable. Replace <yourPassword> and <XXXXXX> with your actual credentials:
REDIS_URL="rediss://default:<yourPassword>@<XXXXXX>.stackhero-network.com:6380"
For more details and advanced options, see the Rails official caching documentation.