View Source MdnsLite.Cache (mdns_lite v0.8.11)

Cache for records received over mDNS

Summary

Types

t()

Timestamp in seconds (assumed monotonic)

Functions

Remove any expired entries

Insert a record into the cache

Insert several record into the cache

Start an empty cache

Run a query against the cache

Types

@type t() :: %MdnsLite.Cache{last_gc: timestamp(), records: [MdnsLite.DNS.dns_rr()]}
@type timestamp() :: integer()

Timestamp in seconds (assumed monotonic)

Functions

@spec gc(t(), timestamp()) :: t()

Remove any expired entries

Link to this function

insert(cache, time, record)

View Source
@spec insert(t(), timestamp(), MdnsLite.DNS.dns_rr()) :: t()

Insert a record into the cache

Link to this function

insert_many(cache, time, records)

View Source
@spec insert_many(t(), timestamp(), [MdnsLite.DNS.dns_rr()]) :: t()

Insert several record into the cache

@spec new() :: %MdnsLite.Cache{last_gc: -2_147_483_648, records: []}

Start an empty cache

@spec query(t(), MdnsLite.DNS.dns_query()) :: %{
  answer: [MdnsLite.DNS.dns_rr()],
  additional: [MdnsLite.DNS.dns_rr()]
}

Run a query against the cache

IMPORTANT: The cache is not garbage collected, so it can return stale entries. Call gc/2 first to expire old entries.