diff options
Diffstat (limited to 'cachecleaner.hh')
-rw-r--r-- | cachecleaner.hh | 13 |
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; |