Class: Puppet::HTTP::DNS::CacheEntry

Inherits:
Object
  • Object
show all
Defined in:
lib/puppet/http/dns.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(records) ⇒ CacheEntry

Returns a new instance of CacheEntry.


9
10
11
12
13
# File 'lib/puppet/http/dns.rb', line 9

def initialize(records)
  @records = records
  @resolution_time = Time.now
  @ttl = choose_lowest_ttl(records)
end

Instance Attribute Details

#recordsObject (readonly)


7
8
9
# File 'lib/puppet/http/dns.rb', line 7

def records
  @records
end

#resolution_timeObject (readonly)


7
8
9
# File 'lib/puppet/http/dns.rb', line 7

def resolution_time
  @resolution_time
end

#ttlObject (readonly)


7
8
9
# File 'lib/puppet/http/dns.rb', line 7

def ttl
  @ttl
end

Instance Method Details

#choose_lowest_ttl(records) ⇒ Object


15
16
17
18
19
20
21
22
23
# File 'lib/puppet/http/dns.rb', line 15

def choose_lowest_ttl(records)
  ttl = records.first.ttl
  records.each do |rec|
    if rec.ttl < ttl
      ttl = rec.ttl
    end
  end
  ttl
end