new(
cfg) ->cache
Create a new DNS cache instance
Configuration fields (all optional):
max_entries — maximum positive cache entries (default 10000, in-memory only)max_negative — maximum negative cache entries (default 5000, in-memory only)min_ttl — minimum TTL floor in seconds (default 30)max_ttl — maximum TTL cap in seconds (default 86400)max_negative_ttl — maximum negative TTL cap in seconds (default 300)sweep_interval — seconds between expired-entry sweeps (default 120, in-memory only)mneme — enable MNEME backend (boolean, opens db at mneme_path)mneme_db — pre-opened MNEME db handle (for sharing with other consumers)mneme_path — MNEME database file path (default /var/cache/recall/dns.mneme)The returned cache object provides these methods:
cache:get(qname, qtype) — returns cached records with adjusted TTLs, or nilcache:put(qname, qtype, records, ttl) — store records with TTL clampingcache:get_negative(qname, qtype) — returns {rcode, soa} for NXDOMAIN/NODATA, or nilcache:put_negative(qname, qtype, rcode, soa_record) — store negative responsecache:sweep() — remove expired entries (in-memory: rate-limited by sweep_interval; MNEME: purge_expired)cache:flush() — clear all entriescache:stats() — returns {backend, size, neg_size}