mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-23 22:15:37 +08:00
refs #494 Ability to "delete" all values in cache.
This commit is contained in:
@@ -278,6 +278,14 @@ namespace BlackMisc
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CValueCache::clearAllValues(const QString &keyPrefix)
|
||||||
|
{
|
||||||
|
QMutexLocker lock(&m_mutex);
|
||||||
|
auto values = getAllValues(keyPrefix);
|
||||||
|
for (auto it = values.begin(); it != values.end(); ++it) { it.value() = CVariant(); }
|
||||||
|
changeValues({ values, QDateTime::currentMSecsSinceEpoch() });
|
||||||
|
}
|
||||||
|
|
||||||
CValueCache::BatchGuard CValueCache::batchChanges(QObject *owner)
|
CValueCache::BatchGuard CValueCache::batchChanges(QObject *owner)
|
||||||
{
|
{
|
||||||
Q_ASSERT(QThread::currentThread() == owner->thread());
|
Q_ASSERT(QThread::currentThread() == owner->thread());
|
||||||
@@ -464,7 +472,7 @@ namespace BlackMisc
|
|||||||
{
|
{
|
||||||
if (! value.isValid())
|
if (! value.isValid())
|
||||||
{
|
{
|
||||||
return CStatusMessage(this, CStatusMessage::SeverityWarning, "Uninitialized value for " + element.m_key);
|
return CStatusMessage(this, CStatusMessage::SeverityDebug, "Uninitialized value for " + element.m_key);
|
||||||
}
|
}
|
||||||
else if (value.userType() != element.m_metaType)
|
else if (value.userType() != element.m_metaType)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -121,6 +121,10 @@ namespace BlackMisc
|
|||||||
//! \threadsafe
|
//! \threadsafe
|
||||||
CStatusMessage loadFromFiles(const QString &directory);
|
CStatusMessage loadFromFiles(const QString &directory);
|
||||||
|
|
||||||
|
//! Clear all values from the cache.
|
||||||
|
//! \threadsafe
|
||||||
|
void clearAllValues(const QString &keyPrefix = {});
|
||||||
|
|
||||||
//! Begins a batch of changes to be made through CCached instances owned by owner.
|
//! Begins a batch of changes to be made through CCached instances owned by owner.
|
||||||
//! \details All changes made through those CCached instances will be deferred until the returned RAII object is
|
//! \details All changes made through those CCached instances will be deferred until the returned RAII object is
|
||||||
//! destroyed. If the destruction happens during stack unwinding due to an exception being thrown, the changes are
|
//! destroyed. If the destruction happens during stack unwinding due to an exception being thrown, the changes are
|
||||||
|
|||||||
Reference in New Issue
Block a user