Reputation: 13404
I've got some reasonable complex data I need to use for a lot of requests. It consists of a hash of different ActiveRecord model objects (though I could only cache the attributes I need instead of the entire object).
I need to access the data frequently and it seems naturally to cache it. It may change infrequently, but not often. I would need to be able to reload the data if it did change, but in general the data seems best as cached.
I'm not using memcached currently, and it seems like overkill to begin using for just one piece of data.
I have some ideas and have experimented with some things but I'd like to get a wider set of recommendations.
Upvotes: 0
Views: 73
Reputation: 1151
Memcached and memcache-client are the obvious ones but there are also other options like cachetastic. Check out something like ruby toolbox to see what else the community likes...
Upvotes: 1
Reputation: 27779
class MyModel < ActiveRecord::Base
def self.my_cached_hash
@my_cached_hash ||= get_my_cached_hash_here
end
def self.reset_my_cached_hash
@my_cached_hash = nil
end
end
Upvotes: 1