return delcount;
}
+uint64_t AuthPacketCache::purgeView(const std::string& view)
+{
+ uint64_t delcount = 0;
+
+ {
+ auto cache = d_cache.write_lock();
+ if (auto iter = cache->find(view); iter != cache->end()) {
+ auto* map = iter->second.get();
+ delcount += purgeLockedCollectionsVector(*map);
+ cache->erase(iter);
+ }
+ }
+
+ *d_statnumentries -= delcount;
+
+ return delcount;
+}
+
/* purges entries from the packetcache. If match ends on a $, it is treated as a suffix */
uint64_t AuthPacketCache::purge(const string &match)
{
uint64_t purge(const std::string& match); // could be $ terminated. Is not a dnsname!
uint64_t purgeExact(const DNSName& qname); // no wildcard matching here
uint64_t purgeExact(const std::string& view, const DNSName& qname); // same as above, but in the given view
+ uint64_t purgeView(const std::string& view);
uint64_t size() const { return *d_statnumentries; };
// Check that requesting from view2 causes a cache miss
BOOST_CHECK_EQUAL(queryPacketCache2(PC, ZC, ComboAddress("192.0.2.1"), qname, innerMask, view2, "2.2.2.2"), false);
+
+ // Cache answers for view1 and view2 again
+ feedPacketCache2(PC, view1, 0x01010101, qname);
+ feedPacketCache2(PC, view2, 0x02020202, qname);
+ BOOST_CHECK_EQUAL(PC.size(), 2);
+
+ // Purge view1
+ BOOST_CHECK_EQUAL(PC.purgeView(view1), 1);
+ BOOST_CHECK_EQUAL(PC.size(), 1);
+
+ // Purge view2
+ BOOST_CHECK_EQUAL(PC.purgeView(view2), 1);
+ BOOST_CHECK_EQUAL(PC.size(), 0);
}
#endif // ] PDNS_AUTH