TTL-aware DNS record cache. Uses in-memory hash tables by default, or MNEME-backed persistent storage when configured.
| Name | Signature |
|---|---|
new | new(cfg) -> cache |
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 nil
cache:put(qname, qtype, records, ttl) — store records with TTL clamping
cache:get_negative(qname, qtype) — returns {rcode, soa} for NXDOMAIN/NODATA, or nil
cache:put_negative(qname, qtype, rcode, soa_record) — store negative response
cache:sweep() — remove expired entries (in-memory: rate-limited by sweep_interval; MNEME: purge_expired)
cache:flush() — clear all entries
cache:stats() — returns {backend, size, neg_size}