Hi, I've made a model cache for rails, to use when you want to cache model instance methods, rather than controller calls. Does anything similar exist already? Any comments on the implementation?
Since it serializes cached data, it might be good to add the following to environment.rb to get YAML-support for the rails class autoloading mechanism.
-- add to environment.rb # YAML support for class autoloading YAML.add_domain_type("ActiveRecord,2007", "") do |type, val| klass = type.split(':').last.constantize YAML.object_maker(klass, val) end
class ActiveRecord::Base def to_yaml_type "!ActiveRecord,2007/#{self.class}" end def to_yaml_properties # only store the attributes ['@attributes'] end end
-- model_cache_helper.rb # ModelCache to use on an ActiveRecord class to cache method calls. Example: