// this function can clean any cache that has an isStale() method on its entries, a preRemoval() method and a 'sequence' index as its second index
// the ritual is that the oldest entries are in *front* of the sequence collection, so on a hit, move an item to the end
// and optionally, on a miss, move it to the beginning
-template <typename S, typename C, typename T>
-void pruneCollection(C& /* container */, T& collection, size_t maxCached, size_t scanFraction = 1000)
+template <typename S, typename T>
+void pruneCollection(T& collection, size_t maxCached, size_t scanFraction = 1000)
{
const time_t now = time(nullptr);
size_t toTrim = 0;
// and nuke everything that is expired
// otherwise, scan first 5*toTrim records, and stop once we've nuked enough
const size_t lookAt = toTrim ? 5 * toTrim : cacheSize / scanFraction;
- size_t tried = 0, erased = 0;
+ size_t tried = 0;
+ size_t erased = 0;
for (auto iter = sidx.begin(); iter != sidx.end() && tried < lookAt; ++tried) {
if (iter->isStale(now)) {
if(now.tv_sec - s_last_prune > (time_t)(30)) {
{
- pruneCollection<SequencedTag>(*this, (*s_metacache.write_lock()), s_maxEntries);
+ pruneCollection<SequencedTag>((*s_metacache.write_lock()), s_maxEntries);
}
{
- pruneCollection<SequencedTag>(*this, (*s_keycache.write_lock()), s_maxEntries);
+ pruneCollection<SequencedTag>((*s_keycache.write_lock()), s_maxEntries);
}
s_last_prune = time(nullptr);
}
void RecursorPacketCache::doPruneTo(size_t maxCached)
{
- pruneCollection<SequencedTag>(*this, d_packetCache, maxCached);
+ pruneCollection<SequencedTag>(d_packetCache, maxCached);
}
uint64_t RecursorPacketCache::doDump(int fd)