11#include <promeki/config.h>
12#if PROMEKI_ENABLE_NETWORK
24PROMEKI_NAMESPACE_BEGIN
55 static constexpr int64_t DefaultMaxTtlSeconds = 3600;
58 static constexpr int64_t DefaultMaxNegativeTtlSeconds = 300;
61 static constexpr size_t DefaultCapacity = 4096;
66 void setMaxTtl(
const Duration &d);
68 Duration maxTtl()
const;
71 void setMaxNegativeTtl(
const Duration &d);
73 Duration maxNegativeTtl()
const;
76 void setCapacity(
size_t cap);
79 size_t capacity()
const;
92 bool negative =
false;
96 List<DnsRecord> records;
107 Hit get(
const String &name, uint16_t type, uint16_t klass)
const;
130 void put(
const String &name, uint16_t type, uint16_t klass,
131 const List<DnsRecord> &records,
132 const Duration &ttlCap = Duration::zero());
147 void putNegative(
const String &name, uint16_t type, uint16_t klass,
148 const DnsRcode &rcode,
149 const Duration &ttlCap = Duration::zero());
154 bool negative =
false;
155 DnsRcode rcode = DnsRcode::NoError;
156 List<DnsRecord> records;
163 bool operator<(
const Key &o)
const {
164 if (name < o.name)
return true;
165 if (o.name < name)
return false;
166 if (type < o.type)
return true;
167 if (type > o.type)
return false;
168 return klass < o.klass;
172 void evictIfOversized();
175 Map<Key, Entry> _entries;
178 size_t _cap = DefaultCapacity;