1

Rails 5.1 app, redis-rails gem 5.0.2

Gemfile

gem "rails", "~> 5.1"
gem "redis-rails"

in production.rb

config.cache_store = :redis_store, ENV.fetch("REDISCLOUD_URL")

in session_store.rb

Rails.application.config.session_store :redis_store, servers: [ENV.fetch("REDISCLOUD_URL")]

I would like to be able to clear cache time to time and I can run

Rails.cache.clear

for that. However, it clears everything and I don't want to remove sessions.

I tried namespaces but can't find much of documentation anywhere (https://github.com/redis-store/redis-rails)

What commands, configs, approach I can take to solve this? Thank you.

AndreiMotinga
  • 1,024
  • 17
  • 24

1 Answers1

2

Maybe you can get all cache keys

Rails.cache.instance_variable_get(:@data).keys

and use it in combination with delete_entry excluding the session keys.

vzamanillo
  • 9,905
  • 1
  • 36
  • 56