swift
|
Encapsulates metastate about how the version of the cache in memory compares to the one on disk. More...
Public Member Functions | |
CDataCacheRevision (const QString &basename) | |
Construct the single instance of the revision metastate. | |
~CDataCacheRevision () | |
Destructor. | |
LockGuard | beginUpdate (const QMap< QString, qint64 > ×tamps, bool updateUuid=true, bool pinsOnly=false) |
Get the state of the disk cache, and prepare to update any values which are out of date. Return value can be converted to bool, false means update is not started (error, or already up-to-date). More... | |
void | writeNewRevision (const QMap< QString, qint64 > ×tamps, const QSet< QString > &excludeKeys={}) |
During update, writes a new revision file with new timestamps. | |
void | regenerate (const CValueCachePacket &keys) |
Write a new revision file with keys deduced from the available JSON files. | |
void | finishUpdate (bool keepPromises=false) |
Release the revision file lock and mark everything up-to-date (called by LockGuard destructor). More... | |
bool | isFound () const |
Existing revision file was found. | |
bool | isPendingRead () const |
True if beginUpdate found some values with timestamps newer than in memory. | |
void | notifyPendingWrite () |
Call before beginUpdate if there is a write pending, so update will start even if there is nothing to read. | |
QSet< QString > | keysWithNewerTimestamps () const |
During update, returns keys which have on-disk timestamps newer than in-memory. Guaranteed not empty. | |
const QMap< QString, qint64 > & | newerTimestamps () const |
During update, returns timestamps which have on-disk timestamps newer than in-memory. Guaranteed not empty. | |
bool | isNewerValueAvailable (const QString &key, qint64 timestamp) |
During update, returns true if the on-disk timestamp of this key is newer than in-memory. | |
std::future< void > | promiseLoadedValue (const QString &key, qint64 currentTimestamp) |
Return a future which will be made ready when the value is loaded. Future is invalid if value is not loading. | |
std::vector< std::promise< void > > | loadedValuePromises () |
Returns (by move) the container of promises to load values. | |
void | breakPromises () |
Abandon all promises. | |
QString | timestampsAsString () const |
Keys with timestamps. | |
void | setTimeToLive (const QString &key, int ttl) |
Set TTL value that will be written to the revision file. | |
void | overrideTimestamp (const QString &key, qint64 timestamp) |
Causes the new timestamp to be written to the revision file. | |
qint64 | getTimestampOnDisk (const QString &key) |
Read the revision file to get a timestamp. | |
void | pinValue (const QString &key) |
Set the flag which will cause the value to be pre-loaded. | |
void | deferValue (const QString &key) |
Set the flag which will cause the value to be deferred-loaded. | |
void | admitValue (const QString &key) |
Set the flag which will cause a deferred-load value to be loaded. | |
void | sessionValue (const QString &key) |
Set the flag which will cause a value to be reset when starting a new session. | |
CDataCacheRevision (const CDataCacheRevision &)=delete | |
Non-copyable. | |
CDataCacheRevision & | operator= (const CDataCacheRevision &)=delete |
Non-copyable. | |
Encapsulates metastate about how the version of the cache in memory compares to the one on disk.
Definition at line 79 of file datacache.h.
LockGuard swift::misc::CDataCacheRevision::beginUpdate | ( | const QMap< QString, qint64 > & | timestamps, |
bool | updateUuid = true , |
||
bool | pinsOnly = false |
||
) |
Get the state of the disk cache, and prepare to update any values which are out of date. Return value can be converted to bool, false means update is not started (error, or already up-to-date).
timestamps | Current in-memory timestamps, to be compared with the on-disk ones. |
updateUuid | Whether to prepare for an actual update, or just interrograte whether one is needed. |
pinsOnly | Only load pinned values. |
void swift::misc::CDataCacheRevision::finishUpdate | ( | bool | keepPromises = false | ) |
Release the revision file lock and mark everything up-to-date (called by LockGuard destructor).
keepPromises | Don't break pending promises. |