Caching template loader, reduces the amount of I/O and improves performance on remote file systems. More...
#include <templatecache.h>
Classes | |
struct | CacheEntry |
Public Member Functions | |
TemplateCache (QSettings *settings, QObject *parent=0) | |
Constructor. | |
Protected Member Functions | |
virtual QString | tryFile (QString localizedName) |
Try to get a file from cache or filesystem. |
Caching template loader, reduces the amount of I/O and improves performance on remote file systems.
The cache has a limited size, it prefers to keep the last recently used files. Optionally, the maximum time of cached entries can be defined to enforce a reload of the template file after a while.
In case of local file system, the use of this cache is optionally, since the operating system caches files already.
Loads localized versions of template files. If the caller requests a file with the name "index" and the suffix is ".tpl" and the requested locale is "de_DE, de, en-US", then files are searched in the following order:
The following settings are required:
path=. suffix=.tpl encoding=UTF-8 cacheSize=1000000 cacheTime=60000
The path is relative to the directory of the config file. In case of windows, if the settings are in the registry, the path is relative to the current working directory.
Files are cached as long as possible, when cacheTime=0.
Definition at line 41 of file templatecache.h.
TemplateCache::TemplateCache | ( | QSettings * | settings, | |
QObject * | parent = 0 | |||
) |
Constructor.
settings | configurations settings | |
parent | Parent object |
Definition at line 6 of file templatecache.cpp.
QString TemplateCache::tryFile | ( | QString | localizedName | ) | [protected, virtual] |
Try to get a file from cache or filesystem.
localizedName | Name of the template with locale to find |
Reimplemented from TemplateLoader.
Definition at line 14 of file templatecache.cpp.