Akonadi

server/storage/collectionstatistics.h
1/*
2 * SPDX-FileCopyrightText: 2014 Daniel Vrátil <dvratil@redhat.com>
3 *
4 * SPDX-License-Identifier: LGPL-2.1-or-later
5 *
6 */
7
8#pragma once
9
10#include <QHash>
11#include <QMutex>
12
13namespace Akonadi
14{
15namespace Server
16{
17class QueryBuilder;
18class Collection;
19
20/**
21 * Provides cache for collection statistics
22 *
23 * Collection statistics are requested very often, so to take some load from the
24 * database we cache the results until the statistics are invalidated (see
25 * NotificationCollector, which takes care for invalidating the statistics).
26 *
27 * The cache (together with optimization of the actual SQL query) seems to
28 * massively improve initial folder listing on system start (when IO and CPU loads
29 * are very high).
30 */
32{
33public:
34 struct Statistics {
35 qint64 count;
36 qint64 size;
37 qint64 read;
38 };
39
40 explicit CollectionStatistics(bool prefetch = true);
41 virtual ~CollectionStatistics() = default;
42
43 Statistics statistics(const Collection &col);
44
45 void itemAdded(const Collection &col, qint64 size, bool seen);
46 void itemsSeenChanged(const Collection &col, qint64 seenCount);
47
48 void invalidateCollection(const Collection &col);
49
50 void expireCache();
51
52protected:
53 QueryBuilder prepareGenericQuery();
54
55 virtual Statistics calculateCollectionStatistics(const Collection &col);
56
57 QMutex mCacheLock;
59};
60
61} // namespace Server
62} // namespace Akonadi
Represents a collection of PIM items.
Definition collection.h:62
Provides cache for collection statistics.
Helper class to construct arbitrary SQL queries.
Helper integration between Akonadi and Qt.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Jul 26 2024 11:52:53 by doxygen 1.11.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.