erldns_packet_cache (erldns v7.0.0-rc1)
View SourceA 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.
Configuration
{erldns, [
{packet_cache, #{
enabled => boolean(), %% defaults to true
ttl => non_neg_integer(), %% Seconds, defaults to 30
}}
]}
Telemetry events
See segmented_cache
for telemetry events under this module name.
Summary
Functions
Clear 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.
Functions
-spec clear() -> any().
Clear the cache
-spec get(dns:questions() | {dns:questions(), dns:additional()}) -> dns:message() | {error, cache_expired | cache_miss}.
Try to retrieve a cached response for the given question.
-spec get(dns:questions() | {dns:questions(), dns:additional()}, undefined | inet:ip_address()) -> dns:message() | {error, cache_expired | cache_miss}.
Try to retrieve a cached response for the given question sent by the given host.
-spec put({dns:questions(), dns:additional()}, dns:message()) -> boolean().
Put the response in the cache for the given question.
Returns if a new record was actually inserted, meaning a duplicate would return false.