mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-04 16:56:53 +08:00
refs #664 Use timestamps from .rev file instead of the filesystem timestamps of the json files.
This commit is contained in:
@@ -257,6 +257,8 @@ namespace BlackMisc
|
||||
{
|
||||
CValueCachePacket newValues;
|
||||
auto msg = m_cache->loadFromFiles(persistentStore(), m_cache->m_revision.keysWithNewerTimestamps(), baseline.toVariantMap(), newValues, m_cache->m_revision.timestampsAsString());
|
||||
newValues.setTimestamps(m_cache->m_revision.newerTimestamps());
|
||||
|
||||
msg.setCategories(this);
|
||||
CLogMessage::preformatted(msg);
|
||||
m_deferredChanges.insert(newValues);
|
||||
@@ -431,6 +433,14 @@ namespace BlackMisc
|
||||
return QSet<QString>::fromList(m_timestamps.keys());
|
||||
}
|
||||
|
||||
const QMap<QString, qint64> &CDataCacheRevision::newerTimestamps() const
|
||||
{
|
||||
QMutexLocker lock(&m_mutex);
|
||||
|
||||
Q_ASSERT(m_updateInProgress);
|
||||
return m_timestamps;
|
||||
}
|
||||
|
||||
bool CDataCacheRevision::isNewerValueAvailable(const QString &key, qint64 timestamp)
|
||||
{
|
||||
QMutexLocker lock(&m_mutex);
|
||||
|
||||
@@ -117,6 +117,9 @@ namespace BlackMisc
|
||||
//! During update, returns keys which have on-disk timestamps newer than in-memory. Guaranteed not empty.
|
||||
QSet<QString> keysWithNewerTimestamps() const;
|
||||
|
||||
//! During update, returns timestamps which have on-disk timestamps newer than in-memory. Guaranteed not empty.
|
||||
const QMap<QString, qint64> &newerTimestamps() const;
|
||||
|
||||
//! During update, returns true if the on-disk timestamp of this key is newer than in-memory.
|
||||
bool isNewerValueAvailable(const QString &key, qint64 timestamp);
|
||||
|
||||
|
||||
@@ -102,6 +102,15 @@ namespace BlackMisc
|
||||
return result.join(",");
|
||||
}
|
||||
|
||||
void CValueCachePacket::setTimestamps(const QMap<QString, qint64> ×)
|
||||
{
|
||||
for (auto it = times.cbegin(); it != times.cend(); ++it)
|
||||
{
|
||||
if (! contains(it.key())) { continue; }
|
||||
(*this)[it.key()].second = it.value();
|
||||
}
|
||||
}
|
||||
|
||||
CValueCachePacket CValueCachePacket::takeByKey(const QString &key)
|
||||
{
|
||||
auto copy = *this;
|
||||
|
||||
@@ -96,6 +96,9 @@ namespace BlackMisc
|
||||
//! Return map of timestamps converted to string.
|
||||
QString toTimestampMapString(const QStringList &keys) const;
|
||||
|
||||
//! Change the timestamps of values.
|
||||
void setTimestamps(const QMap<QString, qint64> &);
|
||||
|
||||
//! Remove value matching the given key, and return it in a separate packet.
|
||||
CValueCachePacket takeByKey(const QString &key);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user