userver
C++ Async Framework
Toggle main menu visibility
Documentation
API Groups
Namespaces
Reference
Class List
Class Index
File List
Macros
All
e
i
l
r
t
u
Functions
Macros
e
i
l
r
t
u
Examples
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Modules
Pages
Concepts
Loading...
Searching...
No Matches
component.hpp
Go to the documentation of this file.
1
#
pragma
once
2
3
/// @file userver/storages/sqlite/component.hpp
4
/// @brief components::SQLite
5
6
#
include
<
userver
/
components
/
component_base
.
hpp
>
7
8
#
include
<
userver
/
utils
/
statistics
/
entry
.
hpp
>
9
10
#
include
<
userver
/
storages
/
sqlite
/
client
.
hpp
>
11
12
USERVER_NAMESPACE_BEGIN
13
14
namespace
components
{
15
16
// clang-format off
17
18
/// @ingroup userver_components
19
///
20
/// @brief SQLite client component
21
///
22
/// Provides access to a SQLite connections via storages::sqlite::Client.
23
///
24
/// ## Static configuration example:
25
///
26
/// ```
27
/// # yaml
28
/// sqlite-dv:
29
/// db-path: "/tmp/kv.db"
30
/// task_processor: fs-task-processor
31
/// journal_mode: wal
32
/// busy_timeout: 1000 # ms
33
/// read_only: false
34
/// initial_read_only_pool_size: 4
35
/// max_read_only_pool_size: 16
36
/// persistent_prepared_statements: true
37
/// cache_size: -65536 # KiB
38
/// foreign_keys: true
39
/// ```
40
/// You must specify either `db-path`.
41
///
42
/// You must specify `blocking_task_processor` as well.
43
///
44
/// Please see [SQLite documentation](https://www.sqlite.org/pragma.html)
45
/// on connection strings.
46
///
47
/// ## Static options:
48
/// Name | Description | Default value
49
/// ---------------------------------- | --------------------------------------------------------------------------------- | ---------------
50
/// fs-task-processor | name of the task processor to handle the blocking file operations | engine::current_task::GetBlockingTaskProcessor()
51
/// db-path | path to the database file or `::memory::` for in-memory mode | -
52
/// create_file | сreate the database file if it does not exist at the specified path | true
53
/// is_read_only | open the database in read-only mode | false
54
/// shared_cache | enable shared in-memory cache for the database | false
55
/// read_uncommitted | allow reading uncommitted data (requires shared_cache) | false
56
/// journal_mode | mode for database journaling | wal
57
/// busy_timeout | timeout duration (in milliseconds) to wait when the database is busy | 5000
58
/// foreign_keys | enable enforcement of foreign key constraints | true
59
/// synchronous | set the level of synchronization to ensure data durability | normal
60
/// cache_size | maximum cache size, specified in number of pages or in kibibytes (negative value) | -2000
61
/// journal_size_limit | limit the size of rollback-journal and WAL files (in bytes) | 67108864
62
/// mmap_size | maximum number of bytes allocated for memory-mapped I/O | 30000000000
63
/// page_size | size of a database page (in bytes) | 4096
64
/// temp_store | storage location for temporary tables and indexes | memory
65
/// persistent-prepared-statements | cache prepared statements for reuse | true
66
/// max_prepared_cache_size | maximum number of prepared statements to cache | 200
67
/// initial_read_only_pool_size | initial size of the read-only connection pool | 5
68
/// max_read_only_pool_size | maximum size of the read-only connection pool | 10
69
70
// clang-format on
71
72
class
SQLite
final
:
public
components
::
ComponentBase
{
73
public
:
74
/// Component constructor
75
SQLite
(
const
ComponentConfig&,
const
ComponentContext&);
76
77
/// Component destructor
78
~
SQLite
()
override
;
79
80
/// Client accessor
81
storages::sqlite::ClientPtr
GetClient
()
const
;
82
83
static
yaml_config
::Schema GetStaticConfigSchema();
84
85
private
:
86
const
storages::sqlite::settings::
SQLiteSettings
settings_;
87
engine::TaskProcessor& fs_task_processor_;
88
const
storages::sqlite::ClientPtr client_;
89
utils
::statistics::Entry statistics_holder_;
90
};
72
class
SQLite
final
:
public
components
::
ComponentBase
{
…
};
91
92
template
<>
93
inline
constexpr
bool
kHasValidate<SQLite> =
true
;
94
95
}
// namespace components
96
97
USERVER_NAMESPACE_END
userver
storages
sqlite
component.hpp
Generated on Fri Jun 20 2025 17:51:47 for userver by
Doxygen
1.13.2