Class: Puppet::Environments::Cached::MRUEntry 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 if it hasn't been touched within ttl_seconds

Instance Attribute Summary

Attributes inherited from Entry

#value

Instance Method Summary collapse

Methods inherited from Entry

#guard, #guarded?, #unguard

Constructor Details

#initialize(value, ttl_seconds) ⇒ MRUEntry

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 MRUEntry.


571
572
573
574
575
576
577
# File 'lib/puppet/environments.rb', line 571

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

  touch
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)

583
584
585
# File 'lib/puppet/environments.rb', line 583

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.


587
588
589
# File 'lib/puppet/environments.rb', line 587

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

#touchObject

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.


579
580
581
# File 'lib/puppet/environments.rb', line 579

def touch
  @ttl = Time.now + @ttl_seconds
end