# module Puppet::Util::Cacher::ClassMethods

Methods that can get added to a class.

### Public Instance Methods

attr_ttl(name) click to toggle source

    # File lib/puppet/util/cacher.rb, line 43
    def attr_ttl(name)
      @attr_ttls[name]
    end

cached_attr(name, ttl, &block) click to toggle source

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..

    # File lib/puppet/util/cacher.rb, line 24
    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|
        # Make sure the cache timestamp is set
        value_cache.synchronize do
          value_cache[name] = value
          set_expiration(name)
        end
      end
    end

set_attr_ttl(name, value) click to toggle source

    # File lib/puppet/util/cacher.rb, line 47
    def set_attr_ttl(name, value)
      @attr_ttls ||= {}
      @attr_ttls[name] = Integer(value)
    end