module Chef::Node::Mixin::DeepMergeCache
Attributes
Cache of deep merged values by top-level key. This is a simple hash which has keys that are the top-level keys of the node object, and we save the computed deep-merge for that key here. There is no cache of subtrees.
Public Class Methods
Source
# File lib/chef/node/mixin/deep_merge_cache.rb, line 29 def initialize @merged_attributes = nil @combined_override = nil @combined_default = nil @deep_merge_cache = Chef::Node::ImmutableMash.new end
Public Instance Methods
Source
# File lib/chef/node/mixin/deep_merge_cache.rb, line 50 def [](key) ret = if deep_merge_cache.key?(key.to_s) # return the cache of the deep merged values by top-level key deep_merge_cache[key.to_s] else # save all the work of computing node[key] deep_merge_cache.internal_set(key.to_s, merged_attributes(key)) end ret = ret.call while ret.is_a?(::Chef::DelayedEvaluator) ret end
Source
# File lib/chef/node/mixin/deep_merge_cache.rb, line 40 def reset_cache(path = nil) if path.nil? deep_merge_cache.regular_clear else deep_merge_cache.regular_delete(path.to_s) end end
Invalidate a key in the deep_merge_cache. If called with nil, or no arg, this will invalidate the entire deep_merge cache. In the case of the user doing node.default[‘bar’]= that eventually results in a call to reset_cache
(‘foo’) here. A node.default=hash_thing call must invalidate the entire cache and re-deep-merge the entire node object.
Also aliased as: reset