Class: Async::DNS::Cache::Entry

Inherits:
Struct
  • Object
show all
Defined in:
lib/async/dns/cache.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#nameObject

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



10
11
12
# File 'lib/async/dns/cache.rb', line 10

def name
  @name
end

#resourceObject

Returns the value of attribute resource

Returns:

  • (Object)

    the current value of resource



10
11
12
# File 'lib/async/dns/cache.rb', line 10

def resource
  @resource
end

#resource_classObject

Returns the value of attribute resource_class

Returns:

  • (Object)

    the current value of resource_class



10
11
12
# File 'lib/async/dns/cache.rb', line 10

def resource_class
  @resource_class
end

#timestampObject

Returns the value of attribute timestamp

Returns:

  • (Object)

    the current value of timestamp



10
11
12
# File 'lib/async/dns/cache.rb', line 10

def timestamp
  @timestamp
end

Instance Method Details

#age(now) ⇒ Object



11
12
13
# File 'lib/async/dns/cache.rb', line 11

def age(now)
  now - timestamp
end

#fresh?(now = Async::Clock.now) ⇒ Boolean

Returns:

  • (Boolean)


15
16
17
18
19
20
21
# File 'lib/async/dns/cache.rb', line 15

def fresh?(now = Async::Clock.now)
  if ttl = resource.ttl
    self.age(now) <= ttl
  else
    true
  end
end