Docs
Ruby
redis-rb, the Rails cache and Sidekiq.
Each example reads the connection URL from VALKEY_URL; copy it from your instance page in the dashboard. See connection details and limits for what applies to every client.
On this page: redis-rb · Rails cache · Sidekiq
redis-rb
The redis gem turns on TLS for rediss:// URLs.
Install
bundle add redisapp.rb
require "redis" redis = Redis.new(url: ENV.fetch("VALKEY_URL")) redis.set("greeting", "hello", ex: 60)puts redis.get("greeting")Rails cache
Use the built-in Redis cache store. It needs the redis gem.
Install
bundle add redisconfig/environments/production.rb
config.cache_store = :redis_cache_store, { url: ENV.fetch("VALKEY_URL"), namespace: "myapp", expires_in: 1.hour,}Sidekiq
Point both the server (workers) and the client (your app) at the same URL.
Install
bundle add sidekiqconfig/initializers/sidekiq.rb
Sidekiq.configure_server do |config| config.redis = { url: ENV.fetch("VALKEY_URL") }end Sidekiq.configure_client do |config| config.redis = { url: ENV.fetch("VALKEY_URL") }endStarter evicts keys when memory is full (allkeys-lru), which can silently drop jobs. Use it for experiments; production queues need a persistent plan with noeviction (Casual or Pro, coming soon).