diff options
author | Luke Kanies <luke@madstop.com> | 2009-05-16 00:08:35 -0500 |
---|---|---|
committer | James Turnbull <james@lovedthanlost.net> | 2009-05-20 18:29:04 +1000 |
commit | 138f19fc6e7bb1d8ebf305decaa045c53787297c (patch) | |
tree | 00cb8da45f0ff7b12fede738b7df9e045a1583a9 /lib/puppet | |
parent | 415553e9485d7ba3ed867033ac9c3315107d3c92 (diff) | |
download | puppet-138f19fc6e7bb1d8ebf305decaa045c53787297c.tar.gz puppet-138f19fc6e7bb1d8ebf305decaa045c53787297c.tar.xz puppet-138f19fc6e7bb1d8ebf305decaa045c53787297c.zip |
Caching whether named autoloaded files are missing
This is the big win, because it causes us to just
skip the whole loading infrastructure, including
skipping looking through the modulepath.
Signed-off-by: Luke Kanies <luke@madstop.com>
Diffstat (limited to 'lib/puppet')
-rw-r--r-- | lib/puppet/util/autoload.rb | 6 | ||||
-rw-r--r-- | lib/puppet/util/autoload/file_cache.rb | 14 |
2 files changed, 18 insertions, 2 deletions
diff --git a/lib/puppet/util/autoload.rb b/lib/puppet/util/autoload.rb index db06ea934..fb15adf92 100644 --- a/lib/puppet/util/autoload.rb +++ b/lib/puppet/util/autoload.rb @@ -73,6 +73,8 @@ class Puppet::Util::Autoload # Load a single plugin by name. We use 'load' here so we can reload a # given plugin. def load(name) + return false if named_file_missing?(name) + path = name.to_s + ".rb" searchpath.each do |dir| @@ -92,10 +94,10 @@ class Puppet::Util::Autoload puts detail.backtrace end end - return false + return named_file_is_missing(name) end end - return false + return named_file_is_missing(name) end # Mark the named object as loaded. Note that this supports unqualified diff --git a/lib/puppet/util/autoload/file_cache.rb b/lib/puppet/util/autoload/file_cache.rb index 6de525a8d..12400f620 100644 --- a/lib/puppet/util/autoload/file_cache.rb +++ b/lib/puppet/util/autoload/file_cache.rb @@ -79,6 +79,20 @@ module Puppet::Util::Autoload::FileCache missing_files[path] = Time.now end + def named_file_missing?(name) + @named_files ||= {} + if time = @named_files[name] and ! data_expired?(time) + return true + end + false + end + + def named_file_is_missing(name) + @named_files ||= {} + @named_files[name] = Time.now + false + end + private def cached_data?(path, type = nil) |