Akonadi

querycache.h
1/*
2 SPDX-FileCopyrightText: 2012 Volker Krause <vkrause@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6
7#pragma once
8
9#include <optional>
10
11class QString;
12class QSqlQuery;
13class QSqlDatabase;
14
15namespace Akonadi
16{
17namespace Server
18{
19/**
20 * A per-thread cache (should be per session, but that'S the same for us) prepared
21 * query cache.
22 */
23namespace QueryCache
24{
25
26/**
27 * Return a cached QSqlQuery for given @p queryStatement.
28 *
29 * If no query is cached for @p queryStatement, an empty optional is returned. Otherwise
30 * the cached query is removed from the cache and must be returned with insert()
31 * after use.
32 */
33std::optional<QSqlQuery> query(const QString &queryStatement);
34
35/// Insert @p query into the cache for @p queryStatement.
36void insert(const QSqlDatabase &db, const QString &queryStatement, QSqlQuery query);
37
38/// Clears all queries from current thread
39void clear();
40
41/// Returns the per-thread capacityof the query cache
42size_t capacity();
43
44} // namespace QueryCache
45
46} // namespace Server
47} // namespace Akonadi
void insert(const QSqlDatabase &db, const QString &queryStatement, QSqlQuery query)
Insert query into the cache for queryStatement.
void clear()
Clears all queries from current thread.
size_t capacity()
Returns the per-thread capacityof the query cache.
std::optional< QSqlQuery > query(const QString &queryStatement)
Return a cached QSqlQuery for given queryStatement.
Helper integration between Akonadi and Qt.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:01:42 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.