Fetcher::DnsCache
Process-wide DNS resolution cache.
Owns its own lock, size cap, and one-shot periodic-cleanup registration.
Pure storage abstraction: the cache does not know about the caller's
cache_enabled policy. Callers gate before calling (see
CrestHttpClient#get_cached_dns and #cache_dns).
Constants
Default size cap for the cache when no explicit value is configured.
Eviction buffer - remove this many entries above the configured cap in a single sweep so we don't evict on every insert at the boundary.
Class methods
Register the periodic cleanup exactly once. Public, self-locking.
Safe to call from anywhere (application init, tests). Internally
split from the unlocked helper because Crystal's Mutex is not
re-entrant and store already holds the lock when it registers.
Lookup a cached address for host. Returns nil if not cached or
expired. Pure read: does not mutate the cache. Expired entries
remain in the cache until clear_expired removes them.
PeriodicCleanup runs clear_expired on a fixed interval (60s by
default) so the cache is bounded in practice.
The cache is a pure storage abstraction; enabling/disabling caching
is the caller's responsibility (see CrestHttpClient#get_cached_dns).
Store addr for host with the given TTL. Registers the periodic
cleanup exactly once.
The cache is a pure storage abstraction; enabling/disabling caching
is the caller's responsibility (see CrestHttpClient#cache_dns).