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

clear()

-spec clear() -> any().

Clean the cache

code_change(PreviousVersion, State, Extra)

get(Key)

-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.

get(Key, Host)

-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.

handle_call(_, From, State)

handle_cast(_, State)

handle_info(Message, State)

init(_)

-spec init([non_neg_integer()]) ->
              {ok,
               #state{ttl :: non_neg_integer(),
                      ttl_overrides :: [{binary(), non_neg_integer()}],
                      tref :: timer:tref()}}.

put(Key, Response)

-spec put(dns:question() | {dns:question(), [dns:rr()]}, dns:message()) -> ok.

Put the response in the cache for the given question.

start_link()

-spec start_link() -> any().

Start the cache.

stop()

-spec stop() -> any().

Stop the cache

sweep()

-spec sweep() -> any().

Remove all old cached packets from the cache.

terminate(Reason, State)