userver
C++ Async Framework (beta)
Loading...
Searching...
No Matches
userver
testsuite
cache_control.hpp
Go to the documentation of this file.
1
#pragma once
2
5
6
#include <functional>
7
#include <string>
8
#include <unordered_set>
9
#include <vector>
10
11
#include <
userver/cache/update_type.hpp
>
12
#include <
userver/components/component_fwd.hpp
>
13
#include <
userver/engine/mutex.hpp
>
14
#include <
userver/utils/not_null.hpp
>
15
16
USERVER_NAMESPACE_BEGIN
17
18
namespace
cache
{
19
class
CacheUpdateTrait;
20
struct
Config;
21
}
// namespace cache
22
23
namespace
testsuite
{
24
27
class
CacheControl
final {
28
public
:
29
enum class
PeriodicUpdatesMode { kDefault, kEnabled, kDisabled };
30
31
explicit
CacheControl
(PeriodicUpdatesMode);
32
34
bool
IsPeriodicUpdateEnabled
(
const
cache::Config
& cache_config,
35
const
std::string& cache_name)
const
;
36
37
void
InvalidateAllCaches(
cache::UpdateType
update_type);
38
39
void
InvalidateCaches(
cache::UpdateType
update_type,
40
std::unordered_set<std::string> names);
41
42
private
:
43
friend
class
CacheInvalidatorHolder
;
44
45
void
RegisterCache(
cache::CacheUpdateTrait
&
cache
);
46
47
void
UnregisterCache(
cache::CacheUpdateTrait
&
cache
);
48
49
const
PeriodicUpdatesMode periodic_updates_mode_;
50
51
engine::Mutex
mutex_;
52
std::vector<utils::NotNull<cache::CacheUpdateTrait*>> caches_;
53
};
54
56
class
CacheInvalidatorHolder
final {
57
public
:
58
CacheInvalidatorHolder
(
CacheControl
&,
cache::CacheUpdateTrait
&);
59
~CacheInvalidatorHolder
();
60
61
CacheInvalidatorHolder
(
const
CacheInvalidatorHolder
&) =
delete
;
62
CacheInvalidatorHolder
(
CacheInvalidatorHolder
&&) =
delete
;
63
CacheInvalidatorHolder
& operator=(
const
CacheInvalidatorHolder
&) =
delete
;
64
CacheInvalidatorHolder
& operator=(
CacheInvalidatorHolder
&&) =
delete
;
65
66
private
:
67
CacheControl
& cache_control_;
68
cache::CacheUpdateTrait
& cache_;
69
};
70
71
}
// namespace testsuite
72
73
USERVER_NAMESPACE_END
Generated on Tue Mar 14 2023 16:21:23 for userver by
Doxygen
1.9.6