When we replace an existing entry, it keeps its existing place in
the expunge queue, while new entries are inserted to the back and
hits are moved to the back.
Moving replaced entries to the back of the queue is more fair and
so probably more efficient, as it would increase the likelihood of
expunging unused expired entries from the cache.
DNSName respname(iter->d_packet.c_str(), iter->d_packet.length(), sizeof(dnsheader), false, 0, 0, 0);
if(qname != respname)
continue;
+ moveCacheItemToBack(d_packetCache, iter);
iter->d_packet = responsePacket;
iter->d_ttd = now + ttl;
iter->d_creation = now;
d_cachecachevalid=false;
cache_t::iterator stored;
+ bool isNew = false;
auto key=boost::make_tuple(qname, qt.getCode(), ednsmask ? *ednsmask : Netmask());
stored=d_cache.find(key);
if(stored == d_cache.end()) {
stored=d_cache.insert(CacheEntry(key,CacheEntry::records_t(), auth)).first;
+ isNew = true;
}
uint32_t maxTTD=UINT_MAX;
// there was code here that did things with TTL and auth. Unsure if it was good. XXX
}
+ if (!isNew) {
+ moveCacheItemToBack(d_cache, stored);
+ }
d_cache.replace(stored, ce);
}