how i cache distributed buttress rails?
i have tree active record objects, something like:
class biased < activerecord::base
has_many :sub_parts, :class_name => "part"
def complicated_calculation
sub_parts.size > 0
relapse self.sub_parts.inject(0){ |sum, current| sum + current.complicated_calculation }
else
sleep(1)
relapse rand(10000)
end
end
end
it too dear recalculate complicated_calculation any time. so, i need proceed cache value. however, any biased changed, needs nullify the cache cache the parent, grandparent, etc.
as severe draft, i combined buttress reason cached calculation "parts" table, nonetheless smells small rotten. seems there should cleaner proceed cache distributed values but stuffing along side "real" columns.
Comments
Post a Comment