Hi,
I misread (or didn't read) the boost::multi_index_container documentation
and assumed 'insert' on a unique index would do 'replace', but of course it
doesn't and shouldn't.
So, I've made this change:
- s_negcache.insert(ne);
+
+ pair res=s_negcache.insert(ne);
+ if(!res.second) {
+ s_negcache.erase(res.first);
+ s_negcache.insert(ne);
+ }
But I can't help feeling there is probably a better and prettier way. Do
people have any suggestions?
In this case, ne is a NegCacheEntry, defined as:
struct NegCacheEntry
{
string d_name;
QType d_qtype;
string d_qname;
uint32_t d_ttd;
};
And the index:
typedef multi_index_container <
NegCacheEntry,
indexed_by <
ordered_unique<
composite_key<
NegCacheEntry,
member,
member
>,
composite_key_compare
>,
ordered_non_unique<
member
>
negcache_t;
Thanks!
--
http://www.PowerDNS.com Open source, database driven DNS Software
http://netherlabs.nl Open and Closed source services