From: Fred Morcos Date: Fri, 27 Oct 2023 22:05:16 +0000 (+0200) Subject: Cleanup UeberBackend cache handling methods X-Git-Tag: rec-5.0.0-beta1~16^2~17 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2f25a437f62ce91451df59ef718a6710bdb17710;p=thirdparty%2Fpdns.git Cleanup UeberBackend cache handling methods --- diff --git a/pdns/ueberbackend.cc b/pdns/ueberbackend.cc index 40584a5321..fd51010bb1 100644 --- a/pdns/ueberbackend.cc +++ b/pdns/ueberbackend.cc @@ -588,11 +588,11 @@ void UeberBackend::cleanup() } // returns -1 for miss, 0 for negative match, 1 for hit -int UeberBackend::cacheHas(const Question& q, vector& rrs) +int UeberBackend::cacheHas(const Question& q, vector& rrs) const { extern AuthQueryCache QC; - if (!d_cache_ttl && !d_negcache_ttl) { + if (d_cache_ttl == 0 && d_negcache_ttl == 0) { return -1; } @@ -603,31 +603,35 @@ int UeberBackend::cacheHas(const Question& q, vector& rrs) if (!ret) { return -1; } - if (rrs.empty()) // negatively cached + if (rrs.empty()) { // negatively cached return 0; + } return 1; } -void UeberBackend::addNegCache(const Question& q) +void UeberBackend::addNegCache(const Question& q) const { extern AuthQueryCache QC; - if (!d_negcache_ttl) + if (d_negcache_ttl == 0) { return; + } // we should also not be storing negative answers if a pipebackend does scopeMask, but we can't pass a negative scopeMask in an empty set! QC.insert(q.qname, q.qtype, vector(), d_negcache_ttl, q.zoneId); } -void UeberBackend::addCache(const Question& q, vector&& rrs) +void UeberBackend::addCache(const Question& q, vector&& rrs) const { extern AuthQueryCache QC; - if (!d_cache_ttl) + if (d_cache_ttl == 0) { return; + } for (const auto& rr : rrs) { - if (rr.scopeMask) + if (rr.scopeMask) { return; + } } QC.insert(q.qname, q.qtype, std::move(rrs), d_cache_ttl, q.zoneId); diff --git a/pdns/ueberbackend.hh b/pdns/ueberbackend.hh index 19b1001fbb..04785d1adb 100644 --- a/pdns/ueberbackend.hh +++ b/pdns/ueberbackend.hh @@ -165,7 +165,7 @@ private: bool d_stale; static bool s_doANYLookupsOnly; - int cacheHas(const Question& q, vector& rrs); - void addNegCache(const Question& q); - void addCache(const Question& q, vector&& rrs); + int cacheHas(const Question& q, vector& rrs) const; + void addNegCache(const Question& q) const; + void addCache(const Question& q, vector&& rrs) const; };