lib/dns-sd/resource_cache.rb in dns-sd-0.1.0 vs lib/dns-sd/resource_cache.rb in dns-sd-0.1.1
- old
+ new
@@ -27,10 +27,14 @@
if @rrcache[k] && @rrcache[k][:expiry] > Time.now
@rrcache[k][:records].dup
else
Resolv::DNS.new.getresources(fqdn, type).tap do |rrs|
- @rrcache[k] = { records: rrs.dup, expiry: Time.now + rrs.map { |rr| rr.ttl }.min }
+ if rrs.empty?
+ @rrcache.delete(k)
+ else
+ @rrcache[k] = { records: rrs.dup, expiry: Time.now + rrs.map { |rr| rr.ttl }.min }
+ end
end
end
end
def entry_expiry_time(fqdn, type)