Rails Tips: Using Class Variables as Cache
Looking for a fast and easy way to persist data across requests? Class Variables as Cache might be your answer
Looking for a fast and easy way to persist data across requests? Class Variables as Cache might be your answer
Comments
Why on earth would you want to do this??
This isn’t a tip. It is a recipe for disaster!
If you rely on this information being there, that could be a problem because the server could be restarted or instances not sharing class variables. But if it’s to cache a long processing that is not meant to change, I’m not sure it’a problem. I think a lot of Rubygems do that no? When they create a singleton with an attr_accessor.
Post a comment