summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/puppet/util/cacher.rb3
-rwxr-xr-xspec/unit/util/cacher.rb7
2 files changed, 8 insertions, 2 deletions
diff --git a/lib/puppet/util/cacher.rb b/lib/puppet/util/cacher.rb
index 0406b12f1..af5c5ebfc 100644
--- a/lib/puppet/util/cacher.rb
+++ b/lib/puppet/util/cacher.rb
@@ -70,7 +70,8 @@ module Puppet::Util::Cacher
end
def cached_value(name)
- if expirer.expired?(cache_timestamp)
+ # Allow a nil expirer, in which case we regenerate the value every time.
+ if expirer.nil? or expirer.expired?(cache_timestamp)
value_cache.clear
@cache_timestamp = Time.now
end
diff --git a/spec/unit/util/cacher.rb b/spec/unit/util/cacher.rb
index 5bdaaaa65..26fe20f84 100755
--- a/spec/unit/util/cacher.rb
+++ b/spec/unit/util/cacher.rb
@@ -51,7 +51,7 @@ describe Puppet::Util::Cacher do
CacheTest.new.expirer.should equal(Puppet::Util::Cacher)
end
- describe "when defining cached attributes" do
+ describe "when using cached attributes" do
before do
@expirer = ExpirerTest.new
@object = CacheTest.new
@@ -90,5 +90,10 @@ describe Puppet::Util::Cacher do
@expirer.expire
@object.instance_cache.should equal(@object.instance_cache)
end
+
+ it "should always consider a value expired if it has no expirer" do
+ @object.stubs(:expirer).returns nil
+ @object.instance_cache.should_not equal(@object.instance_cache)
+ end
end
end