18#ifndef QGSCONFIGCACHE_H
19#define QGSCONFIGCACHE_H
23#include "qgis_server.h"
29#include <QDomDocument>
30#include <QFileSystemWatcher>
49 virtual QString
name()
const = 0;
121 QList<QgsProject *> projects()
const;
144 QDomDocument *xmlDocument( const QString &filePath );
146 QCache<QString, QDomDocument> mXmlDocumentCache;
147 QCache<QString, std::pair<QDateTime, std::unique_ptr<
QgsProject>>> mProjectCache;
180 QString
name()
const override {
return QStringLiteral(
"filesystem" ); };
189 void entryRemoved(
const QString &path )
override;
195 void entryInserted(
const QString &path )
override;
199 QFileSystemWatcher mFileSystemWatcher;
219 QString
name()
const override {
return QStringLiteral(
"periodic" ); };
227 void setCheckInterval(
int msec );
239 void entryRemoved(
const QString &path )
override;
245 void entryInserted(
const QString &path )
override;
269 QString
name()
const override {
return QStringLiteral(
"off" ); };
278 void entryRemoved(
const QString &path )
override;
284 void entryInserted(
const QString &path )
override;
Abstract base class for implementing cache invalidation strategy.
virtual void attach(QgsConfigCache *cache)=0
Attache cache to this strategy.
virtual void entryInserted(const QString &path)=0
Called when an entry is removed from cache.
virtual ~QgsAbstractCacheStrategy()=default
virtual QString name() const =0
The name of the strategy.
virtual void entryRemoved(const QString &path)=0
Called when an entry is removed from cache.
Cache for server configuration.
QgsConfigCache(QgsServerSettings *settings)
Initialize from settings.
void removeChangedEntry(const QString &path)
Remove cache entry.
void removeEntry(const QString &path)
Removes an entry from cache.
QString strategyName() const
Returns the name of the current strategy.
void removeChangedEntries()
Remove all changed cache entries.
static QgsConfigCache * instance()
Returns the current instance.
static void initialize(QgsServerSettings *settings)
Initialize from settings.
void projectRemovedFromCache(const QString &path)
Emitted whenever a project is removed from the cache.
const QgsProject * project(const QString &path, const QgsServerSettings *settings=nullptr)
If the project is not cached yet, then the project is read from the path.
QgsFileSystemCacheStrategy()
Creates a new filesystem strategy.
QString name() const override
The name of the strategy.
QgsNullCacheStrategy()=default
Creates a new null strategy.
QString name() const override
The name of the strategy.
QgsPeriodicCacheStrategy(int interval=3000)
Creates a new periodic strategy.
int checkInterval() const
Returns the invalidation check interval.
QString name() const override
The name of the strategy.
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
Provides a way to retrieve settings by prioritizing according to environment variables,...