]> granicus.if.org Git - pdns/commitdiff
query cache hit/miss statistics
authorKees Monshouwer <mind04@monshouwer.org>
Wed, 19 Apr 2017 22:59:37 +0000 (00:59 +0200)
committermind04 <mind04@monshouwer.org>
Thu, 20 Apr 2017 20:47:19 +0000 (22:47 +0200)
pdns/auth-querycache.cc

index e91349c5abbdac996a1f2e4eca3716ec1cd5d420..e9c9e7b6e163e6e5f4b1b56f430b74219e1a77f5 100644 (file)
@@ -31,8 +31,6 @@ extern StatBag S;
 
 const unsigned int AuthQueryCache::s_mincleaninterval, AuthQueryCache::s_maxcleaninterval;
 
-extern StatBag S;
-
 AuthQueryCache::AuthQueryCache(size_t mapsCount): d_lastclean(time(nullptr))
 {
   d_maps.resize(mapsCount);
@@ -128,13 +126,18 @@ bool AuthQueryCache::getEntryLocked(cmap_t& map, const DNSName &qname, uint16_t
   auto& idx = boost::multi_index::get<HashTag>(map);
   auto iter = idx.find(tie(qname, qtype, zoneID));
 
-  if (iter == idx.end())
+  if (iter == idx.end()) {
+    (*d_statnummiss)++;
     return false;
+  }
 
-  if (iter->ttd < now)
+  if (iter->ttd < now) {
+    (*d_statnummiss)++;
     return false;
+  }
 
   value = iter->drs;
+  (*d_statnumhit)++;
   return true;
 }