18#ifndef QGSCONFIGCACHE_H
19#define QGSCONFIGCACHE_H
23#include "qgis_server.h"
29#include <QDomDocument>
30#include <QFileSystemWatcher>
35using namespace Qt::StringLiterals;
52 virtual QString
name()
const = 0;
123 QList<QgsProject *> projects()
const;
146 QDomDocument *xmlDocument( const QString &filePath );
148 QCache<QString, QDomDocument> mXmlDocumentCache;
149 QCache<QString, std::pair<QDateTime, std::unique_ptr<
QgsProject>>> mProjectCache;
182 QString
name()
const override {
return u
"filesystem"_s; };
191 void entryRemoved(
const QString &path )
override;
197 void entryInserted(
const QString &path )
override;
201 QFileSystemWatcher mFileSystemWatcher;
220 QString
name()
const override {
return u
"periodic"_s; };
228 void setCheckInterval(
int msec );
240 void entryRemoved(
const QString &path )
override;
246 void entryInserted(
const QString &path )
override;
270 QString
name()
const override {
return u
"off"_s; };
279 void entryRemoved(
const QString &path )
override;
285 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,...