mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-25 07:08:11 +00:00
feat(MainDb): getConferenceNotifiedEvents supports events cache
This commit is contained in:
parent
7dd5d96717
commit
d9f022bb3f
2 changed files with 26 additions and 3 deletions
|
|
@ -108,6 +108,12 @@ private:
|
|||
long long insertConferenceParticipantDeviceEvent (const std::shared_ptr<EventLog> &eventLog);
|
||||
long long insertConferenceSubjectEvent (const std::shared_ptr<EventLog> &eventLog);
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Cache API.
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
std::shared_ptr<EventLog> getEventFromCache (long long eventId) const;
|
||||
|
||||
L_DECLARE_PUBLIC(MainDb);
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -536,6 +536,19 @@ MainDb::MainDb (const shared_ptr<Core> &core) : AbstractDb(*new MainDbPrivate),
|
|||
return eventId;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
shared_ptr<EventLog> MainDbPrivate::getEventFromCache (long long eventId) const {
|
||||
auto it = storageIdToEvent.find(eventId);
|
||||
if (it == storageIdToEvent.cend())
|
||||
return nullptr;
|
||||
|
||||
shared_ptr<EventLog> eventLog = it->second.lock();
|
||||
// Must exist. If not, implementation bug.
|
||||
L_ASSERT(eventLog);
|
||||
return eventLog;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
void MainDb::init () {
|
||||
|
|
@ -920,13 +933,17 @@ MainDb::MainDb (const shared_ptr<Core> &core) : AbstractDb(*new MainDbPrivate),
|
|||
soci::transaction tr(*session);
|
||||
|
||||
soci::rowset<soci::row> rows = (session->prepare << query, soci::use(peerAddress), soci::use(lastNotifyId));
|
||||
for (const auto &row : rows)
|
||||
events.push_back(d->selectGenericConferenceEvent(
|
||||
getBackend() == Sqlite3 ? static_cast<long long>(row.get<int>(0)) : row.get<long long>(0),
|
||||
for (const auto &row : rows) {
|
||||
long long eventId = getBackend() == Sqlite3 ? static_cast<long long>(row.get<int>(0)) : row.get<long long>(0);
|
||||
shared_ptr<EventLog> eventLog = d->getEventFromCache(eventId);
|
||||
|
||||
events.push_back(eventLog ? eventLog : d->selectGenericConferenceEvent(
|
||||
eventId,
|
||||
static_cast<EventLog::Type>(row.get<int>(1)),
|
||||
Utils::getTmAsTimeT(row.get<tm>(2)),
|
||||
peerAddress
|
||||
));
|
||||
}
|
||||
|
||||
L_END_LOG_EXCEPTION
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue