summaryrefslogtreecommitdiffstats
path: root/cachecleaner.hh
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-13 21:14:51 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-13 21:14:51 +0000
commitbc282425088455198a7a99511c75914477d4ed32 (patch)
tree1b1fb887a634136a093deea7e4dd95d054201e7a /cachecleaner.hh
parentReleasing progress-linux version 1.8.3-3~progress7.99u1. (diff)
downloaddnsdist-bc282425088455198a7a99511c75914477d4ed32.tar.xz
dnsdist-bc282425088455198a7a99511c75914477d4ed32.zip
Merging upstream version 1.9.3.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'cachecleaner.hh')
-rw-r--r--cachecleaner.hh13
1 files changed, 6 insertions, 7 deletions
diff --git a/cachecleaner.hh b/cachecleaner.hh
index 9ec8e13..aaf7981 100644
--- a/cachecleaner.hh
+++ b/cachecleaner.hh
@@ -130,10 +130,9 @@ uint64_t pruneLockedCollectionsVector(std::vector<T>& maps)
return totErased;
}
-template <typename S, typename C, typename T>
-uint64_t pruneMutexCollectionsVector(C& container, std::vector<T>& maps, uint64_t maxCached, uint64_t cacheSize)
+template <typename S, typename T>
+uint64_t pruneMutexCollectionsVector(time_t now, std::vector<T>& maps, uint64_t maxCached, uint64_t cacheSize)
{
- const time_t now = time(nullptr);
uint64_t totErased = 0;
uint64_t toTrim = 0;
uint64_t lookAt = 0;
@@ -164,10 +163,10 @@ uint64_t pruneMutexCollectionsVector(C& container, std::vector<T>& maps, uint64_
uint64_t lookedAt = 0;
for (auto i = sidx.begin(); i != sidx.end(); lookedAt++) {
if (i->isStale(now)) {
- container.preRemoval(*shard, *i);
+ shard->preRemoval(*i);
i = sidx.erase(i);
erased++;
- --content.d_entriesCount;
+ content.decEntriesCount();
}
else {
++i;
@@ -224,9 +223,9 @@ uint64_t pruneMutexCollectionsVector(C& container, std::vector<T>& maps, uint64_
auto& sidx = boost::multi_index::get<S>(shard->d_map);
size_t removed = 0;
for (auto i = sidx.begin(); i != sidx.end() && removed < toTrimForThisShard; removed++) {
- container.preRemoval(*shard, *i);
+ shard->preRemoval(*i);
i = sidx.erase(i);
- --content.d_entriesCount;
+ content.decEntriesCount();
++totErased;
if (--toTrim == 0) {
return totErased;