Update QtWebapp to 1.7.11

This commit is contained in:
Felix Kauselmann
2020-07-30 12:28:05 +02:00
parent 3de099491f
commit b9c48cc4b6
31 changed files with 796 additions and 307 deletions

View File

@ -3,7 +3,9 @@
#include <QStringList>
#include <QSet>
TemplateCache::TemplateCache(QSettings* settings, QObject* parent)
using namespace stefanfrings;
TemplateCache::TemplateCache(const QSettings* settings, QObject* parent)
:TemplateLoader(settings,parent)
{
cache.setMaxCost(settings->value("cacheSize","1000000").toInt());
@ -11,14 +13,16 @@ TemplateCache::TemplateCache(QSettings* settings, QObject* parent)
qDebug("TemplateCache: timeout=%i, size=%i",cacheTimeout,cache.maxCost());
}
QString TemplateCache::tryFile(QString localizedName)
QString TemplateCache::tryFile(const QString localizedName)
{
qint64 now=QDateTime::currentMSecsSinceEpoch();
mutex.lock();
// search in cache
qDebug("TemplateCache: trying cached %s",qPrintable(localizedName));
CacheEntry* entry=cache.object(localizedName);
if (entry && (cacheTimeout==0 || entry->created>now-cacheTimeout))
{
mutex.unlock();
return entry->document;
}
// search on filesystem
@ -27,6 +31,7 @@ QString TemplateCache::tryFile(QString localizedName)
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());
mutex.unlock();
return entry->document;
}