I’m basically trying to cache tweets in my Rails 3 app so I don’t have to get them on every page refresh. I have two class variables:
@@tweet_time = Time.now
@@tweets = Twitter.user_timeline(TWEET_ACCOUNT)[0,NUMBER_OF_TWEETS]
Those are in my controller.
In the controller, I check to see if
@@tweet_time < 1.hour.ago
and if so I reset @@tweets and @@tweet_time.
But when I try to loop through @@tweets in the view, it says @@tweets is an uninitialized class variable. I guess that is because technically it is being called from ActionView instead of ActionController.
How can I access @@tweets in the view?
PS If I am doing this completely backwards, feel free to critique and hopefully offer me a better way. I really do appreciate any feedback you can offer.
I am using the “dalli” gem to do this now. It is a speedy way to use MemCache from what I can tell.