Documentation ¶
Overview ¶
Package cacheddns resolves domains caching the result in memory to avoid hitting the DNS server too often.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CachedDomain ¶
type CachedDomain struct {
// contains filtered or unexported fields
}
CachedDomain stores info about the cached domain in memory.
func New ¶
func New(domain string, ttl time.Duration) *CachedDomain
New creates a new cached domain in memory. This will NOT call the DNS server yet.
func (*CachedDomain) Get ¶
func (c *CachedDomain) Get() (string, bool)
Get returns the currently cached address and a true flag. If it has not been resolved yet or the TTL has passed it will return an empty string with the flag set to false. It's recommended to use Resolve() directly instead.
func (*CachedDomain) Resolve ¶
func (c *CachedDomain) Resolve() (string, error)
Resolve returns the cached address or checks with the DNS server the setting if the TTL has expired. It returns the first address found.
func (*CachedDomain) Update ¶
func (c *CachedDomain) Update() (string, error)
Update the cached address if needed and return it. Any connection error will be returned. It's recommended to use Resolve() directly instead.