I've written a cron job to update some cached values in the background (rather than doing it while a user waits). I have a scenario that runs that cron job and then reads the cache to see if the values are set correctly.
The problem is that Rails.cache.read("key")
is returning "Cache read: key\n"
not the value, and if I debug and inspect Rails.cache
I get a ActiveSupport::Cache::BlackHoleStore
returned - not a good sign.
This makes sense of course because the following is included in my cucumber.env
:
config.action_controller.perform_caching = false
require File.join(RAILS_ROOT, 'lib', 'black_hole_store.rb')
config.cache_store = :black_hole_store
What I want is to override this at runtime - we have about a thousand scenarios and this is the only one that needs the cache active. I tried the following from the debugger prompt without any luck:
(rdb:1) ActionController::Base.perform_caching = true
true
(rdb:1) ActionController::Base.perform_caching
true
(rdb:1) Rails.cache
#<ActiveSupport::Cache::BlackHoleStore:0x101b6dc60 @logger_off=false>
(rdb:1) ActionController::Base.cache_store = :memory_store
:memory_store
(rdb:1) Rails.cache
#<ActiveSupport::Cache::BlackHoleStore:0x101b6dc60 @logger_off=false>
Anyone know how to do this?