A resolver that wraps another one with an ETS cache.
Answers are kept for their TTL, capped at one hour. "No such name" and "no such record" answers are kept too, as RFC 2308 says. Temporary failures are not kept.
Start it in your supervision tree:
children = [
{MailAuth.Resolver.Cached, resolver: MailAuth.Resolver.Inet, max_size: 10_000}
]and use it:
MailAuth.authenticate(raw, resolver: MailAuth.Resolver.Cached)Options for start_link/1:
:name: the cache's name. DefaultMailAuth.Resolver.Cached. With another name, passcache: nameto every call:resolver: the resolver to ask on a miss. DefaultMailAuth.Resolver.Inet:max_size: the most answers to keep. Default 10 000:max_ttl: the longest time to keep an answer, in seconds. Default 3600
When the cache is full, expired answers are removed first; if it is still full, the oldest answers go.
Summary
Functions
@spec clear(atom()) :: :ok
Removes every answer from the cache.
@spec start_link(keyword()) :: GenServer.on_start()
Starts the cache.