1
votes

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.

1
I coded a small tools to clear the cache: github.com/BorisBresciani/rails_web_cacheBoris BRESCIANI

1 Answers

2
votes

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.