Index: server/src/cachecleaner.h =================================================================== --- server/src/cachecleaner.h (revision 915886) +++ server/src/cachecleaner.h (working copy) @@ -46,6 +46,10 @@ private slots: void cleanCache(); + private: + short int mTime; + qint64 mLoops; + }; } Index: server/src/cachecleaner.cpp =================================================================== --- server/src/cachecleaner.cpp (revision 915886) +++ server/src/cachecleaner.cpp (working copy) @@ -29,6 +29,8 @@ CacheCleaner::CacheCleaner(QObject * parent) : QThread( parent ) { + mTime = 60; + mLoops = 0; } CacheCleaner::~CacheCleaner() @@ -38,14 +40,14 @@ void CacheCleaner::run() { DataStore::self(); - QTimer::singleShot( 60 * 1000, this, SLOT(cleanCache()) ); + QTimer::singleShot( mTime * 1000, this, SLOT(cleanCache()) ); exec(); DataStore::self()->close(); } void CacheCleaner::cleanCache() { - + qint64 LoopsWithExpiredItem = 0; // cycle over all collection QList collections = Collection::retrieveAll(); foreach ( Collection collection, collections ) { @@ -83,9 +85,20 @@ if ( !parts[ i ].update() ) qDebug() << "failed to update item part" << parts[ i ].id(); } + LoopsWithExpiredItem++; } - QTimer::singleShot( 60 * 1000, this, SLOT(cleanCache()) ); + if( mLoops < LoopsWithExpiredItem) { + if( mTime > 60) + mTime -= 60; + } else { + if( mTime < 600) + mTime +=60; + } + + mLoops = (LoopsWithExpiredItem + mLoops) >> 2; + + QTimer::singleShot( mTime * 1000, this, SLOT(cleanCache()) ); } #include "cachecleaner.moc"