erldns_packet_cache (erldns v13.0.0)
View SourceA basic packet cache that is used to avoid multiple lookups for the same question received within the cache TTL.
In order to work correctly, it should be added to the packet pipeline twice,
once early in the processing pipeline, after erldns_edns and erldns_questions, and once
after the resolver.
Names are compared case-insensitively, and an answer from the cache carries the ID, RD bit and question of the request it answers.
An answer is looked up by the question and the additional section as it is at that point, which
holds the response's OPT RR (see erldns_edns). A pipe that adds an option depending on the
query must run before the first cache, so that queries asking for different options are cached
apart.
Configuration
{erldns, [
{packet_cache, #{
enabled => boolean(), %% defaults to true
ttl => non_neg_integer(), %% Seconds, defaults to 30
}}
]}Telemetry events
[erldns, pipeline, cache]spans as triggered bysegmented_cache.
Summary
Functions
erldns_pipeline:call/2 callback.
Clear the cache
erldns_pipeline:deps/0 callback.
erldns_pipeline:prepare/1 callback.
Functions
-spec call(dns:message(), erldns_pipeline:opts()) -> erldns_pipeline:return().
erldns_pipeline:call/2 callback.
-spec clear() -> true.
Clear the cache
-spec deps() -> erldns_pipeline:deps().
erldns_pipeline:deps/0 callback.
-spec prepare(erldns_pipeline:opts()) -> disabled | erldns_pipeline:opts().
erldns_pipeline:prepare/1 callback.