const size_t maxPerShard = upTo / d_shardCount;
size_t removed = 0;
- uint32_t shardIndex = 0;
-
- do {
- auto& shard = d_shards.at(shardIndex);
- ++shardIndex;
+ for (auto& shard : d_shards) {
WriteLock w(&shard.d_lock);
auto& map = shard.d_map;
if (map.size() <= maxPerShard) {
}
}
}
- while (shardIndex < d_shardCount);
return removed;
}
{
size_t removed = 0;
- for (uint32_t shardIndex = 0; shardIndex < d_shardCount; shardIndex++) {
- WriteLock w(&d_shards.at(shardIndex).d_lock);
- auto& map = d_shards[shardIndex].d_map;
+ for (auto& shard : d_shards) {
+ WriteLock w(&shard.d_lock);
+ auto& map = shard.d_map;
for(auto it = map.begin(); it != map.end(); ) {
const CacheValue& value = it->second;
if ((value.qname == name || (suffixMatch && value.qname.isPartOf(name))) && (qtype == QType::ANY || qtype == value.qtype)) {
it = map.erase(it);
- --d_shards[shardIndex].d_entriesCount;
+ --shard.d_entriesCount;
++removed;
} else {
++it;