Class: Puppet::Environments::Cached::TTLEntry Private

Inherits:
Entry show all
Defined in:
lib/puppet/environments.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Policy that expires in ttl_seconds from when it was created

Direct Known Subclasses

MRUEntry

Instance Attribute Summary

Attributes inherited from Entry

#value

Instance Method Summary collapse

Methods inherited from Entry

#guard, #guarded?, #touch, #unguard

Constructor Details

#initialize(value, ttl_seconds) ⇒ TTLEntry

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of TTLEntry.



575
576
577
578
579
# File 'lib/puppet/environments.rb', line 575

def initialize(value, ttl_seconds)
  super(value)
  @ttl = Time.now + ttl_seconds
  @ttl_seconds = ttl_seconds
end

Instance Method Details

#expired?(now) ⇒ Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


581
582
583
# File 'lib/puppet/environments.rb', line 581

def expired?(now)
  now > @ttl
end

#labelObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



585
586
587
# File 'lib/puppet/environments.rb', line 585

def label
  "(ttl = #{@ttl_seconds} sec)"
end