I am trying to cache a class variable like this:
Rails.cache.write("@@page_types", @@page_types)
This method is called inside the class, which I called PageTypes.
If I run the rails console and do:
Rails.cache.write("@@page_types", nil) Rails.cache.read("@@page_types")
I get zero. I leave the console open and do it in another window:
rake test: units
When the tests are finished, I will return to the rails console window and do
Rails.cache.read("@@page_types")
It returns an array of my test pages! I am sure they are from my db test, because all models have super-high identifiers, while my dev data has very low values.
I suppose I could add Rails.env to the cache keys, but it looks like the two caches shouldn't mix ...
source share