View Source erldns_packet_cache (erldns v4.2.0)
A basic packet cache that is used to avoid multiple lookups for the same question received within the cache TTL.
The cache is swept for old cache data at regular intervals.
Summary
Functions
Clean the cache
Try to retrieve a cached response for the given question.
Try to retrieve a cached response for the given question sent by the given host.
Put the response in the cache for the given question.
Start the cache.
Stop the cache
Remove all old cached packets from the cache.
Functions
-spec clear() -> any().
Clean the cache
-spec get(dns:question() | {dns:question(), [dns:rr()]}) -> {ok, dns:message()} | {error, cache_expired} | {error, cache_miss}.
Try to retrieve a cached response for the given question.
-spec get(dns:question() | {dns:question(), [dns:rr()]}, dns:ip()) -> {ok, dns:message()} | {error, cache_expired} | {error, cache_miss}.
Try to retrieve a cached response for the given question sent by the given host.
-spec init([non_neg_integer()]) -> {ok, #state{ttl :: non_neg_integer(), ttl_overrides :: [{binary(), non_neg_integer()}], tref :: timer:tref()}}.
-spec put(dns:question() | {dns:question(), [dns:rr()]}, dns:message()) -> ok.
Put the response in the cache for the given question.
-spec start_link() -> any().
Start the cache.
-spec stop() -> any().
Stop the cache
-spec sweep() -> any().
Remove all old cached packets from the cache.