void QgsMSLayerCache::removeProjectFileLayers( const QString& project ) { QgsMessageLog::logMessage( "Removing cache entries for project file: " + project, "Server", QgsMessageLog::INFO ); QVector< QPair< QString, QString > > removeEntries; QVector< QgsMSLayerCacheEntry > removeEntriesValues; QHash<QPair<QString, QString>, QgsMSLayerCacheEntry>::iterator entryIt = mEntries.begin(); for ( ; entryIt != mEntries.end(); ++entryIt ) { if ( entryIt.value().configFile == project ) { removeEntries.push_back( entryIt.key() ); removeEntriesValues.push_back( entryIt.value() ); freeEntryRessources( entryIt.value() ); } } for ( int i = 0; i < removeEntries.size(); ++i ) { const QgsMSLayerCacheEntry& removeEntry = removeEntriesValues.at( i ); const QPair< QString, QString > removeKey = removeEntries.at( i ); QgsMessageLog::logMessage( "Removing cache entry for url:" + removeKey.first + " layerName:" + removeKey.second + " project file:" + project, "Server", QgsMessageLog::INFO ); mEntries.remove( removeKey, removeEntry ); } }
void QgsMSLayerCache::removeLeastUsedEntry() { if ( mEntries.size() < 1 ) { return; } QHash<QPair<QString, QString>, QgsMSLayerCacheEntry>::iterator it = mEntries.begin(); QHash<QPair<QString, QString>, QgsMSLayerCacheEntry>::iterator lowest_it = it; time_t lowest_time = it->lastUsedTime; for ( ; it != mEntries.end(); ++it ) { if ( it->lastUsedTime < lowest_time ) { lowest_it = it; lowest_time = it->lastUsedTime; } } QgsMessageLog::logMessage( "Removing last accessed layer '" + lowest_it.value().layerPointer->name() + "' project file " + lowest_it.value().configFile + " from cache" , "Server", QgsMessageLog::INFO ); freeEntryRessources( *lowest_it ); mEntries.erase( lowest_it ); }
void QgsMSLayerCache::removeLeastUsedEntry() { if ( mEntries.size() < 1 ) { return; } QgsDebugMsg( "removeLeastUsedEntry" ); QHash<QPair<QString, QString>, QgsMSLayerCacheEntry>::iterator it = mEntries.begin(); QHash<QPair<QString, QString>, QgsMSLayerCacheEntry>::iterator lowest_it = it; time_t lowest_time = it->lastUsedTime; for ( ; it != mEntries.end(); ++it ) { if ( it->lastUsedTime < lowest_time ) { lowest_it = it; lowest_time = it->lastUsedTime; } } freeEntryRessources( *lowest_it ); mEntries.erase( lowest_it ); }