lib/puppet/util/cacher.rb
# Provide a means of defining an attribute whose value will be cached.
# Must provide a block capable of defining the value if it's flushed..
Provide a means of defining an attribute whose value will be cached.
Must provide a block capable of defining the value if it's flushed
Provide a means of defining an attribute whose value will be cached . Must provide a block capable of defining the value if it ' s flushed
def cached_attr(name, ttl, &block)
      init_method = "init_#{name}"
      define_method(init_method, &block)
      set_attr_ttl(name, ttl)
      define_method(name) do
        cached_value(name)
      end
      define_method(name.to_s + "=") do |value|
        value_cache.synchronize do
          value_cache[name] = value
          set_expiration(name)
        end
      end
    end
def cached_attr ( name , ttl , & block ) init_method = "init_#{name}" define_method ( init_method , & block ) set_attr_ttl ( name , ttl ) define_method ( name ) do cached_value ( name ) end define_method ( name . to_s + "=" ) do | value | value_cache . synchronize do value_cache [ name ] = value set_expiration ( name ) end end end
Provide a means of defining an attribute whose value will be cached.
Provide a means of defining an attribute whose value will be cached .
# Make sure the cache timestamp is set
name
<not_specific>
ttl
<not_specific>
block
<not_specific>