Github   Telegram
Loading...
Searching...
No Matches
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
15
16USERVER_NAMESPACE_BEGIN
17
18namespace cache {
19class CacheUpdateTrait;
20struct Config;
21} // namespace cache
22
23namespace testsuite {
24
27class 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
57 public:
60
63 CacheInvalidatorHolder& operator=(const CacheInvalidatorHolder&) = delete;
65
66 private:
67 CacheControl& cache_control_;
69};
70
71} // namespace testsuite
72
73USERVER_NAMESPACE_END