Method: Puppet::Indirector::Indirection#expire

Defined in:
lib/puppet/indirector/indirection.rb

#expire(key, options = {}) ⇒ Object

Expire a cached object, if one is cached. Note that we don’t actually remove it, we expire it and write it back out to disk. This way people can still use the expired object if they want.



162
163
164
165
166
167
168
169
170
171
172
173
174
175
# File 'lib/puppet/indirector/indirection.rb', line 162

def expire(key, options={})
  request = request(:expire, key, nil, options)

  return nil unless cache?

  return nil unless instance = cache.find(request(:find, key, nil, options))

  Puppet.info _("Expiring the %{cache} cache of %{instance}") % { cache: self.name, instance: instance.name }

  # Set an expiration date in the past
  instance.expiration = Time.now - 60

  cache.save(request(:save, nil, instance, options))
end