userver
C++ Async Framework
Toggle main menu visibility
Loading...
Searching...
No Matches
cache_update_trait.hpp
Go to the documentation of this file.
1
#pragma once
2
5
6
#include <memory>
7
#include <string>
8
9
#include <
userver/cache/cache_statistics.hpp
>
10
#include <
userver/cache/update_type.hpp
>
11
#include <
userver/components/component_fwd.hpp
>
12
#include <
userver/dump/fwd.hpp
>
13
#include <
userver/engine/task/task_processor_fwd.hpp
>
14
#include <
userver/rcu/fwd.hpp
>
15
#include <
userver/utils/flags.hpp
>
16
17
USERVER_NAMESPACE_BEGIN
18
19
namespace
cache
{
20
21
struct
CacheDependencies;
22
struct
Config
;
23
30
class
CacheUpdateTrait {
31
public
:
32
CacheUpdateTrait(CacheUpdateTrait&&) =
delete
;
33
CacheUpdateTrait& operator=(CacheUpdateTrait&&) =
delete
;
34
37
void
InvalidateAsync
(
UpdateType
update_type);
38
69
void
UpdateSyncDebug
(
UpdateType
update_type);
70
72
const
std::string&
Name
() const noexcept;
73
74
protected:
76
// For internal use only
77
CacheUpdateTrait(const
components
::ComponentConfig& config, const
components
::ComponentContext& context);
78
79
// For internal use only
80
explicit CacheUpdateTrait(CacheDependencies&& dependencies);
81
82
virtual ~CacheUpdateTrait();
84
86
AllowedUpdateTypes
GetAllowedUpdateTypes
() const;
87
89
enum class
Flag
{
90
kNone = 0,
91
94
kNoFirstUpdate
= 1 << 0,
95
};
96
99
void
OnCacheModified
() noexcept;
100
102
// For internal use only
103
rcu
::ReadablePtr<
Config
> GetConfig() const;
104
105
// Checks for the presence of the flag for pre-assign check.
106
// For internal use only.
107
bool
HasPreAssignCheck() const noexcept;
108
109
// Returns value of the flag safe-data-lifetime.
110
// For internal use only.
111
bool
IsSafeDataLifetime() const noexcept;
112
113
// For internal use only.
114
void
SetDataSizeStatistic(
std
::
size_t
size) noexcept;
115
116
// For internal use only
117
// TODO remove after TAXICOMMON-3959
118
engine
::
TaskProcessor
& GetCacheTaskProcessor() const noexcept;
120
158
virtual
void
Update
(
159
UpdateType
type,
160
const
std
::chrono::system_clock::time_point& last_update,
161
const
std
::chrono::system_clock::time_point& now,
162
UpdateStatisticsScope
& stats_scope
163
) = 0;
164
166
virtual
utils
::Flags<
Flag
>
GetStartFlags
() const;
167
170
void
EarlyStartPeriodicUpdates
(
utils
::Flags<
Flag
> flags);
171
173
// For internal use only
174
void
EarlyStopPeriodicUpdates();
176
177
private:
178
void
StartPeriodicUpdates();
179
180
void
StopPeriodicUpdates();
181
182
virtual
void
Cleanup() = 0;
183
184
virtual
void
MarkAsExpired();
185
186
virtual
void
GetAndWrite(
dump
::Writer& writer) const;
187
188
virtual
void
ReadAndSet(
dump
::Reader& reader);
189
190
class Impl;
191
std
::unique_ptr<Impl> impl_;
192
};
193
194
}
// namespace cache
195
196
USERVER_NAMESPACE_END
userver
cache
cache_update_trait.hpp
Generated on
for userver by
Doxygen
1.17.0