1 #include "templatecache.h"
6 using namespace stefanfrings;
11 cache.setMaxCost(settings->value(
"cacheSize",
"1000000").toInt());
12 cacheTimeout=settings->value(
"cacheTime",
"60000").toInt();
13 long int cacheMaxCost=(
long int)cache.maxCost();
14 qDebug(
"TemplateCache: timeout=%i, size=%li",cacheTimeout,cacheMaxCost);
19 qint64 now=QDateTime::currentMSecsSinceEpoch();
22 qDebug(
"TemplateCache: trying cached %s",qPrintable(localizedName));
23 CacheEntry* entry=cache.object(localizedName);
24 if (entry && (cacheTimeout==0 || entry->created>now-cacheTimeout))
27 return entry->document;
30 entry=
new CacheEntry();
34 cache.insert(localizedName,entry,entry->document.size());
36 return entry->document;
virtual QString tryFile(const QString localizedName)
Try to get a file from cache or filesystem.
TemplateCache(const QSettings *settings, QObject *parent=nullptr)
Constructor.
Loads localized versions of template files.
virtual QString tryFile(const QString localizedName)
Try to get a file from cache or filesystem.