mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-07-31 11:20:22 +02:00
Add a QCache to cache recent hits in memory
This commit is contained in:
@@ -136,6 +136,7 @@ InfoSystemCache::getCachedInfoSlot( const Tomahawk::InfoSystem::InfoCriteriaHash
|
|||||||
|
|
||||||
fileLocationHash.remove( criteriaHashVal );
|
fileLocationHash.remove( criteriaHashVal );
|
||||||
m_fileLocationCache[type] = fileLocationHash;
|
m_fileLocationCache[type] = fileLocationHash;
|
||||||
|
m_dataCache.remove( criteriaHashVal );
|
||||||
|
|
||||||
emit notInCache( criteria, caller, type, input, customData );
|
emit notInCache( criteria, caller, type, input, customData );
|
||||||
return;
|
return;
|
||||||
@@ -155,10 +156,16 @@ InfoSystemCache::getCachedInfoSlot( const Tomahawk::InfoSystem::InfoCriteriaHash
|
|||||||
m_fileLocationCache[type] = fileLocationHash;
|
m_fileLocationCache[type] = fileLocationHash;
|
||||||
}
|
}
|
||||||
|
|
||||||
QSettings cachedSettings( fileLocationHash[criteriaHashVal], QSettings::IniFormat );
|
if ( !m_dataCache.contains( criteriaHashVal ) )
|
||||||
QVariant output = cachedSettings.value( "data" );
|
{
|
||||||
|
QSettings cachedSettings( fileLocationHash[criteriaHashVal], QSettings::IniFormat );
|
||||||
emit info( caller, type, input, output, customData );
|
QVariant output = cachedSettings.value( "data" );
|
||||||
|
m_dataCache.insert( criteriaHashVal, new QVariant( output ) );
|
||||||
|
|
||||||
|
emit info( caller, type, input, output, customData );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
emit info( caller, type, input, QVariant( *(m_dataCache[criteriaHashVal]) ), customData );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -184,6 +191,8 @@ InfoSystemCache::updateCacheSlot( const Tomahawk::InfoSystem::InfoCriteriaHash c
|
|||||||
|
|
||||||
QSettings cachedSettings( fileLocationHash[criteriaHashVal], QSettings::IniFormat );
|
QSettings cachedSettings( fileLocationHash[criteriaHashVal], QSettings::IniFormat );
|
||||||
cachedSettings.setValue( "data", output );
|
cachedSettings.setValue( "data", output );
|
||||||
|
|
||||||
|
m_dataCache.insert( criteriaHashVal, new QVariant( output ) );
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -209,6 +218,7 @@ InfoSystemCache::updateCacheSlot( const Tomahawk::InfoSystem::InfoCriteriaHash c
|
|||||||
|
|
||||||
fileLocationHash[criteriaHashVal] = settingsFilePath;
|
fileLocationHash[criteriaHashVal] = settingsFilePath;
|
||||||
m_fileLocationCache[type] = fileLocationHash;
|
m_fileLocationCache[type] = fileLocationHash;
|
||||||
|
m_dataCache.insert( criteriaHashVal, new QVariant( output ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -19,6 +19,7 @@
|
|||||||
#ifndef TOMAHAWK_INFOSYSTEMCACHE_H
|
#ifndef TOMAHAWK_INFOSYSTEMCACHE_H
|
||||||
#define TOMAHAWK_INFOSYSTEMCACHE_H
|
#define TOMAHAWK_INFOSYSTEMCACHE_H
|
||||||
|
|
||||||
|
#include <QCache>
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QtDebug>
|
#include <QtDebug>
|
||||||
@@ -58,6 +59,7 @@ private:
|
|||||||
QString m_cacheBaseDir;
|
QString m_cacheBaseDir;
|
||||||
QHash< InfoType, QHash< QString, QString > > m_fileLocationCache;
|
QHash< InfoType, QHash< QString, QString > > m_fileLocationCache;
|
||||||
QTimer m_pruneTimer;
|
QTimer m_pruneTimer;
|
||||||
|
QCache< QString, QVariant > m_dataCache;
|
||||||
};
|
};
|
||||||
|
|
||||||
} //namespace InfoSystem
|
} //namespace InfoSystem
|
||||||
|
Reference in New Issue
Block a user