Luis Ángel San Martín f4e55729a2 fixed comiplation in Linux (Ubuntu)
line 117: #define _WIN64 1
must be removed in ./compressed_archive/libp7zip/CPP/myWindows/StdAfx.h

"cannot find -lpulse" compiling under Qt 5.0.2 can be fixed creating a symbolic link from libpulse.so.0 to libpulse.so (further research is needed)
2013-12-08 11:50:10 -08:00

31 lines
1.1 KiB
C++

#include "templatecache.h"
#include <QDateTime>
#include <QStringList>
#include <QSet>
TemplateCache::TemplateCache(QSettings* settings, QObject* parent)
:TemplateLoader(settings,parent)
{
cache.setMaxCost(settings->value("cacheSize","160000").toInt());//este tamaño antes era 1000000
cacheTimeout=settings->value("cacheTime","60000").toInt();
qDebug("TemplateCache: timeout=%i, size=%i",cacheTimeout,cache.maxCost());
}
QString TemplateCache::tryFile(QString localizedName) {
qint64 now=QDateTime::currentMSecsSinceEpoch();
// search in cache
qDebug("TemplateCache: trying cached %s",qPrintable(localizedName));
CacheEntry* entry=cache.object(localizedName);
if (entry && (cacheTimeout==0 || entry->created>now-cacheTimeout)) {
return entry->document;
}
// search on filesystem
entry=new CacheEntry();
entry->created=now;
entry->document=TemplateLoader::tryFile(localizedName);
// Store in cache even when the file did not exist, to remember that there is no such file
cache.insert(localizedName,entry,entry->document.size());
return entry->document;
}