diff options
author | Luke Kanies <luke@madstop.com> | 2008-11-11 13:01:14 -0800 |
---|---|---|
committer | Luke Kanies <luke@madstop.com> | 2008-11-11 13:01:14 -0800 |
commit | 29b97943e7efaad3cb3f8e7b82004c067d3fbf82 (patch) | |
tree | 1abb306a834786f2681249c762c57dcd21ebd7bd | |
parent | cd09d6b90d3365d06e8e706aab3edbd8f568f1c9 (diff) | |
download | puppet-29b97943e7efaad3cb3f8e7b82004c067d3fbf82.tar.gz puppet-29b97943e7efaad3cb3f8e7b82004c067d3fbf82.tar.xz puppet-29b97943e7efaad3cb3f8e7b82004c067d3fbf82.zip |
Allowing a nil expirer for caching classes.
If there's no expirer, then the value is regenerated every
time.
Signed-off-by: Luke Kanies <luke@madstop.com>
-rw-r--r-- | lib/puppet/util/cacher.rb | 3 | ||||
-rwxr-xr-x | spec/unit/util/cacher.rb | 7 |
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 |