uint16_t qt = qtype.getCode();
//cerr<<"Lookup for maxReplyLen: "<<maxReplyLen<<endl;
auto& mc=getMap(qname);
- cmap_t::const_iterator i=mc.d_map.find(tie(qname, qt, cet, zoneID, meritsRecursion, maxReplyLen, dnssecOK, hasEDNS, *age));
+ // cmap_t::const_iterator i=mc.d_map.find(tie(qname, qt, cet, zoneID, meritsRecursion, maxReplyLen, dnssecOK, hasEDNS, *age));
+
+ auto& idx = boost::multi_index::get<UnorderedNameTag>(mc.d_map);
+ auto range=idx.equal_range(tie(qname, qt, cet, zoneID));
+
+ if(range.first == range.second)
+ return false;
time_t now=time(0);
- bool ret=(i!=mc.d_map.end() && i->ttd > now);
- if(ret) {
- if (age)
- *age = now - i->created;
- value = i->value;
+ for(auto iter = range.first ; iter != range.second; ++iter) {
+ if(meritsRecursion == iter->meritsRecursion && maxReplyLen == iter->maxReplyLen && dnssecOK == iter->dnssecOk && hasEDNS == iter->hasEDNS ) {
+ if(iter->ttd > now) {
+ if (age)
+ *age = now - iter->created;
+ value = iter->value;
+ return true;
+ }
+ }
}
- return ret;
+ return false;
}
bool PacketCache::getEntryLocked(const DNSName &qname, const QType& qtype, CacheEntryType cet, vector<DNSZoneRecord>& value, int zoneID)
uint16_t qt = qtype.getCode();
//cerr<<"Lookup for maxReplyLen: "<<maxReplyLen<<endl;
auto& mc=getMap(qname);
- cmap_t::const_iterator i=mc.d_map.find(tie(qname, qt, cet, zoneID));
+ auto& idx = boost::multi_index::get<UnorderedNameTag>(mc.d_map);
+ auto i=idx.find(tie(qname, qt, cet, zoneID));
+ if(i==idx.end())
+ return false;
+
time_t now=time(0);
- bool ret=(i!=mc.d_map.end() && i->ttd > now);
- if(ret) {
+ if(i->ttd > now) {
value = i->drs;
+ return true;
}
- return ret;
+ return false;
}
using namespace ::boost::multi_index;
#include "namespaces.hh"
+#include <boost/multi_index/hashed_index.hpp>
#include "dnspacket.hh"
#include "lock.hh"
#include "statbag.hh"
void getTTLS();
+ struct UnorderedNameTag{};
typedef multi_index_container<
CacheEntry,
indexed_by <
>,
composite_key_compare<CanonDNSNameCompare, std::less<uint16_t>, std::less<uint16_t>, std::less<int>, std::less<bool>,
std::less<unsigned int>, std::less<bool>, std::less<bool> >
- >,
- sequenced<>
+ >,
+ hashed_non_unique<tag<UnorderedNameTag>, composite_key<CacheEntry,
+ member<CacheEntry,DNSName,&CacheEntry::qname>,
+ member<CacheEntry,uint16_t,&CacheEntry::qtype>,
+ member<CacheEntry,uint16_t, &CacheEntry::ctype>,
+ member<CacheEntry,int, &CacheEntry::zoneID> > > ,
+ sequenced<>
>
> cmap_t;