6#include <userver/cache/base_postgres_cache_fwd.hpp>
13#include <unordered_map>
15#include <fmt/format.h>
17#include <userver/cache/cache_statistics.hpp>
18#include <userver/cache/caching_component_base.hpp>
19#include <userver/components/component_config.hpp>
20#include <userver/components/component_context.hpp>
22#include <userver/storages/postgres/cluster.hpp>
23#include <userver/storages/postgres/component.hpp>
24#include <userver/storages/postgres/io/chrono.hpp>
26#include <userver/compiler/demangle.hpp>
27#include <userver/engine/sleep.hpp>
28#include <userver/logging/log.hpp>
29#include <userver/tracing/span.hpp>
30#include <userver/utils/assert.hpp>
31#include <userver/utils/cpu_relax.hpp>
32#include <userver/utils/meta.hpp>
33#include <userver/utils/shared_readable_ptr.hpp>
34#include <userver/yaml_config/merge_schemas.hpp>
36USERVER_NAMESPACE_BEGIN
40namespace pg_cache::detail {
43using ValueType =
typename T::ValueType;
45concept HasValueType =
requires {
typename T::ValueType; };
48struct RawValueTypeImpl : std::type_identity<ValueType<T>> {};
51concept HasRawValueType =
requires {
typename T::RawValueType; };
53template <HasRawValueType T>
54struct RawValueTypeImpl<T> : std::type_identity<
typename T::RawValueType> {};
57using RawValueType =
typename RawValueTypeImpl<T>::type;
59template <
typename PostgreCachePolicy>
60auto ExtractValue(RawValueType<PostgreCachePolicy>&& raw) {
61 if constexpr (HasRawValueType<PostgreCachePolicy>) {
62 return Convert(std::move(raw), formats::
parse::
To<ValueType<PostgreCachePolicy>>());
64 return std::move(raw);
70concept HasName =
requires {
71 requires !std::string_view { T::kName }
77concept HasQuery =
requires { T::kQuery; };
81concept HasGetQuery =
requires { T::GetQuery(); };
85concept HasWhere =
requires { T::kWhere; };
89concept HasOrderBy =
requires { T::kOrderBy; };
93concept HasTag =
requires { T::kTag; };
95template <
typename PostgreCachePolicy>
97 if constexpr (HasTag<PostgreCachePolicy>) {
98 return PostgreCachePolicy::kTag;
106concept HasUpdatedField =
requires { T::kUpdatedField; };
109concept WantIncrementalUpdates =
requires {
111 std::integral_constant<
bool, !std::string_view{T::kUpdatedField}.empty()>{}
112 } -> std::same_as<std::true_type>;
117concept HasKeyMember =
requires { T::kKeyMember; } && std::invocable<
decltype(T::kKeyMember), ValueType<T>>;
120using KeyMemberType = std::decay_t<std::invoke_result_t<
decltype(T::kKeyMember), ValueType<T>>>;
124concept HasSizeMethod =
requires(T t) {
127 } -> std::convertible_to<std::size_t>;
132concept HasInsertOrAssignMethod =
requires(
typename T::CacheContainer& c, KeyMemberType<T> key, ValueType<T> val) {
133 c.insert_or_assign(std::move(key), std::move(val));
138concept HasCacheInsertOrAssignFunction =
139 requires(
typename T::CacheContainer& c, ValueType<T> val, KeyMemberType<T> key) {
140 CacheInsertOrAssign(c, std::move(val), std::move(key));
144concept PolicyHasCustomCacheContainer =
requires {
typename T::CacheContainer; };
148struct DataCacheContainer {
151 "With default CacheContainer, key type must be std::hash-able"
154 using type = std::unordered_map<KeyMemberType<T>, ValueType<T>>;
158requires PolicyHasCustomCacheContainer<T>
159struct DataCacheContainer<T> {
160 static_assert(HasSizeMethod<
typename T::CacheContainer>,
"Custom CacheContainer must provide `size` method");
162 HasInsertOrAssignMethod<T> || HasCacheInsertOrAssignFunction<T>,
163 "Custom CacheContainer must provide `insert_or_assign` method similar to std::unordered_map's "
164 "one or CacheInsertOrAssign function"
167 using type =
typename T::CacheContainer;
171using DataCacheContainerType =
typename DataCacheContainer<T>::type;
176inline constexpr bool kIsContainerCopiedByElement =
177 meta::IsInstantiationOf<T, std::unordered_map> || meta::IsInstantiationOf<T, std::map>;
180std::unique_ptr<T> CopyContainer(
182 [[maybe_unused]] std::size_t cpu_relax_iterations,
185 if constexpr (kIsContainerCopiedByElement<T>) {
186 auto copy = std::make_unique<T>();
188 copy->reserve(container.size());
192 for (
const auto& kv : container) {
198 return std::make_unique<T>(container);
202template <
typename Container,
typename Value,
typename KeyMember,
typename... Args>
203void CacheInsertOrAssign(Container& container, Value&& value,
const KeyMember& key_member, Args&&... ) {
205 static_assert(
sizeof...(Args) == 0);
207 auto key = std::invoke(key_member, value);
208 container.insert_or_assign(std::move(key), std::forward<Value>(value));
212void OnWritesDone(T& container) {
213 if constexpr (
requires(T& c) { c.OnWritesDone(); }) {
214 container.OnWritesDone();
219class CopyOnWriteData
final {
221 explicit CopyOnWriteData(
utils::SharedReadablePtr<T> current)
222 : current_data_(std::move(current))
224 if (!current_data_) {
225 new_data_ = std::make_unique<T>();
229 const T& GetLatestData()
const {
return new_data_ ? *new_data_ : *current_data_; }
231 bool NeedsCopy()
const noexcept {
return new_data_ ==
nullptr; }
233 T& GetOrCreateNewData(std::size_t cpu_relax_iterations, tracing::
ScopeTime& scope) {
235 new_data_ = CopyContainer(*current_data_, cpu_relax_iterations, scope);
240 std::size_t GetCopiedSize()
const noexcept {
return current_data_ && new_data_ ? current_data_->size() : 0; }
242 std::unique_ptr<T> ReleaseNewData() && {
244 return std::move(new_data_);
248 utils::SharedReadablePtr<T> current_data_;
249 std::unique_ptr<T> new_data_;
253concept HasCustomUpdated =
requires(
const DataCacheContainerType<T>& cache) { T::GetLastKnownUpdated(cache); };
256struct UpdatedFieldTypeImpl : std::type_identity<storages::
postgres::TimePointTz> {};
259concept HasUpdatedFieldType =
requires {
typename T::UpdatedFieldType; };
261template <HasUpdatedFieldType T>
262struct UpdatedFieldTypeImpl<T> : std::type_identity<
typename T::UpdatedFieldType> {};
265using UpdatedFieldType =
typename UpdatedFieldTypeImpl<T>::type;
268constexpr bool CheckUpdatedFieldType() {
269 if constexpr (HasUpdatedFieldType<T>) {
270#if USERVER_POSTGRES_ENABLE_LEGACY_TIMESTAMP
272 std::is_same_v<
typename T::UpdatedFieldType, storages::postgres::TimePointTz> ||
273 std::is_same_v<
typename T::UpdatedFieldType, storages::postgres::TimePointWithoutTz> ||
274 std::is_same_v<
typename T::UpdatedFieldType, storages::postgres::TimePoint> || HasCustomUpdated<T>,
275 "Invalid UpdatedFieldType, must be either TimePointTz or "
277 "or (legacy) system_clock::time_point"
281 std::is_same_v<
typename T::UpdatedFieldType, storages::
postgres::TimePointTz> ||
282 std::is_same_v<
typename T::UpdatedFieldType, storages::
postgres::TimePointWithoutTz> ||
284 "Invalid UpdatedFieldType, must be either TimePointTz or "
290 !WantIncrementalUpdates<T>,
291 "UpdatedFieldType must be explicitly specified when using "
292 "incremental updates"
300constexpr storages::
postgres::ClusterHostTypeFlags ClusterHostType() {
301 if constexpr (
requires { T::kClusterHostType; }) {
302 return T::kClusterHostType;
310constexpr bool MayReturnNull() {
311 if constexpr (
requires { T::kMayReturnNull; }) {
312 return T::kMayReturnNull;
318template <
typename PostgreCachePolicy>
319struct PolicyChecker {
321 static_assert(HasName<PostgreCachePolicy>,
"The PosgreSQL cache policy must contain a static member `kName`");
322 static_assert(HasValueType<PostgreCachePolicy>,
"The PosgreSQL cache policy must define a type alias `ValueType`");
324 HasKeyMember<PostgreCachePolicy>,
325 "The PostgreSQL cache policy must contain a static member `kKeyMember` "
326 "with a pointer to a data or a function member with the object's key"
329 HasQuery<PostgreCachePolicy> || HasGetQuery<PostgreCachePolicy>,
330 "The PosgreSQL cache policy must contain a static data member "
331 "`kQuery` with a select statement or a static member function "
332 "`GetQuery` returning the query"
335 !(HasQuery<PostgreCachePolicy> && HasGetQuery<PostgreCachePolicy>),
336 "The PosgreSQL cache policy must define `kQuery` or "
337 "`GetQuery`, not both"
340 HasUpdatedField<PostgreCachePolicy>,
341 "The PosgreSQL cache policy must contain a static member "
342 "`kUpdatedField`. If you don't want to use incremental updates, "
343 "please set its value to `nullptr`"
345 static_assert(CheckUpdatedFieldType<PostgreCachePolicy>());
348 ClusterHostType<PostgreCachePolicy>() & storages::
postgres::kClusterHostRolesMask,
349 "Cluster host role must be specified for caching component, "
350 "please be more specific"
353 static storages::
postgres::Query GetQuery() {
354 if constexpr (HasGetQuery<PostgreCachePolicy>) {
355 return PostgreCachePolicy::GetQuery();
357 return PostgreCachePolicy::kQuery;
364inline constexpr std::chrono::minutes kDefaultFullUpdateTimeout{1};
365inline constexpr std::chrono::seconds kDefaultIncrementalUpdateTimeout{1};
366inline constexpr std::chrono::milliseconds kStatementTimeoutOff{0};
367inline constexpr std::chrono::milliseconds kCpuRelaxThreshold{10};
368inline constexpr std::chrono::milliseconds kCpuRelaxInterval{2};
370inline constexpr std::string_view kCopyStage =
"copy_data";
371inline constexpr std::string_view kFetchStage =
"fetch";
372inline constexpr std::string_view kParseStage =
"parse";
374inline constexpr std::size_t kDefaultChunkSize = 1000;
375inline constexpr std::chrono::milliseconds kDefaultSleepBetweenChunks{0};
383template <
typename PostgreCachePolicy>
384class PostgreCache
final :
public pg_cache::detail::PolicyChecker<PostgreCachePolicy>::BaseType {
387 using PolicyType = PostgreCachePolicy;
388 using ValueType = pg_cache::detail::ValueType<PolicyType>;
389 using RawValueType = pg_cache::detail::RawValueType<PolicyType>;
390 using DataType = pg_cache::detail::DataCacheContainerType<PolicyType>;
391 using PolicyCheckerType = pg_cache::detail::PolicyChecker<PostgreCachePolicy>;
392 using UpdatedFieldType = pg_cache::detail::UpdatedFieldType<PostgreCachePolicy>;
393 using BaseType =
typename PolicyCheckerType::BaseType;
396 constexpr static bool kIncrementalUpdates = pg_cache::detail::WantIncrementalUpdates<PolicyType>;
397 constexpr static auto kClusterHostTypeFlags = pg_cache::detail::ClusterHostType<PolicyType>();
398 constexpr static auto kName = PolicyType::kName;
400 PostgreCache(
const ComponentConfig&,
const ComponentContext&);
402 static yaml_config::Schema GetStaticConfigSchema();
405 using UpdateData = pg_cache::detail::CopyOnWriteData<DataType>;
408 const storages::
postgres::Query& query;
410 UpdatedFieldType last_updated;
418 UpdatedFieldType GetLastUpdated(std::chrono::system_clock::time_point last_update,
const DataType& cache)
const;
422 const std::chrono::system_clock::time_point& last_update,
423 const std::chrono::system_clock::time_point& now,
424 cache::UpdateStatisticsScope& stats_scope
427 bool MayReturnNull()
const override;
430 DataType& GetOrCreateNewData(UpdateData& data, tracing::
ScopeTime& scope);
431 std::size_t UpdateFromCluster(
433 const QueryParams& params,
435 cache::UpdateStatisticsScope& stats_scope,
440 const QueryParams& params,
441 cache::UpdateStatisticsScope& stats_scope
443 FirstChunk FetchFirstChunk(storages::
postgres::
Cluster& cluster,
const QueryParams& params);
444 std::size_t CacheAllChunks(
446 const QueryParams& params,
448 cache::UpdateStatisticsScope& stats_scope,
451 std::size_t CacheNonEmptyResults(
454 cache::UpdateStatisticsScope& stats_scope,
459 DataType& data_cache,
460 cache::UpdateStatisticsScope& stats_scope,
464 static storages::
postgres::Query GetAllQuery();
465 static storages::
postgres::Query GetDeltaQuery();
466 static std::string GetWhereClause();
467 static std::string GetDeltaWhereClause();
468 static std::string GetOrderByClause();
470 std::chrono::milliseconds ParseCorrection(
const ComponentConfig& config);
474 const std::chrono::system_clock::duration correction_;
475 const std::chrono::milliseconds full_update_timeout_;
476 const std::chrono::milliseconds incremental_update_timeout_;
477 const std::size_t chunk_size_;
478 const std::chrono::milliseconds sleep_between_chunks_;
479 std::size_t cpu_relax_iterations_parse_{0};
480 std::size_t cpu_relax_iterations_copy_{0};
483template <
typename PostgreCachePolicy>
484inline constexpr bool kHasValidate<PostgreCache<PostgreCachePolicy>> =
true;
486template <
typename PostgreCachePolicy>
487PostgreCache<PostgreCachePolicy>::PostgreCache(
const ComponentConfig& config,
const ComponentContext& context)
488 : BaseType{config, context},
489 correction_{ParseCorrection(config)},
490 full_update_timeout_{
491 config
["full-update-op-timeout"].As<std
::chrono
::milliseconds
>(pg_cache::detail::kDefaultFullUpdateTimeout
)
493 incremental_update_timeout_{
494 config
["incremental-update-op-timeout"]
495 .As<std
::chrono
::milliseconds
>(pg_cache::detail::kDefaultIncrementalUpdateTimeout
)
497 chunk_size_{config
["chunk-size"].As<size_t
>(pg_cache::detail::kDefaultChunkSize
)},
498 sleep_between_chunks_{
499 config
["sleep-between-chunks"].As<std
::chrono
::milliseconds
>(pg_cache::detail::kDefaultSleepBetweenChunks
)
504 "Either set 'chunk-size' to 0, or enable PostgreSQL portals by building "
505 "the framework with CMake option USERVER_FEATURE_PATCH_LIBPQ set to ON."
509 throw std::logic_error(
510 "Incremental update support is requested in config but no update field "
511 "name is specified in traits of '" +
515 if (correction_.count() < 0) {
516 throw std::logic_error(
517 "Refusing to set forward (negative) update correction requested in "
523 const auto pg_alias = config
["pgcomponent"].As<std
::string
>("");
524 if (pg_alias.empty()) {
529 clusters_.resize(shard_count);
530 for (size_t i = 0; i < shard_count; ++i) {
539template <
typename PostgreCachePolicy>
540std::string PostgreCache<PostgreCachePolicy>::GetWhereClause() {
541 if constexpr (pg_cache::detail::HasWhere<PostgreCachePolicy>) {
542 return fmt::format(FMT_COMPILE(
"where {}"), PostgreCachePolicy::kWhere);
548template <
typename PostgreCachePolicy>
549std::string PostgreCache<PostgreCachePolicy>::GetDeltaWhereClause() {
550 if constexpr (pg_cache::detail::HasWhere<PostgreCachePolicy>) {
552 FMT_COMPILE(
"where ({}) and {} >= $1"),
553 PostgreCachePolicy::kWhere,
554 PostgreCachePolicy::kUpdatedField
557 return fmt::format(FMT_COMPILE(
"where {} >= $1"), PostgreCachePolicy::kUpdatedField);
561template <
typename PostgreCachePolicy>
562std::string PostgreCache<PostgreCachePolicy>::GetOrderByClause() {
563 if constexpr (pg_cache::detail::HasOrderBy<PostgreCachePolicy>) {
564 return fmt::format(FMT_COMPILE(
"order by {}"), PostgreCachePolicy::kOrderBy);
570template <
typename PostgreCachePolicy>
571storages::
postgres::Query PostgreCache<PostgreCachePolicy>::GetAllQuery() {
572 const storages::
postgres::Query query = PolicyCheckerType::GetQuery();
576template <
typename PostgreCachePolicy>
577storages::
postgres::Query PostgreCache<PostgreCachePolicy>::GetDeltaQuery() {
578 if constexpr (kIncrementalUpdates) {
579 const storages::
postgres::Query query = PolicyCheckerType::GetQuery();
585 return GetAllQuery();
589template <
typename PostgreCachePolicy>
590std::chrono::milliseconds PostgreCache<PostgreCachePolicy>::ParseCorrection(
const ComponentConfig& config) {
591 static constexpr std::string_view kUpdateCorrection =
"update-correction";
592 if (pg_cache::detail::HasCustomUpdated<PostgreCachePolicy> ||
595 return config
[kUpdateCorrection
].As<std
::chrono
::milliseconds
>(0
);
597 return config
[kUpdateCorrection
].As<std
::chrono
::milliseconds
>();
601template <
typename PostgreCachePolicy>
602typename PostgreCache<PostgreCachePolicy>::UpdatedFieldType PostgreCache<PostgreCachePolicy>::GetLastUpdated(
603 [[maybe_unused]] std::chrono::system_clock::time_point last_update,
604 const DataType& cache
606 if constexpr (pg_cache::detail::HasCustomUpdated<PostgreCachePolicy>) {
607 return PostgreCachePolicy::GetLastKnownUpdated(cache);
609 return UpdatedFieldType{last_update - correction_};
613template <
typename PostgreCachePolicy>
614void PostgreCache<PostgreCachePolicy>::Update(
616 const std::chrono::system_clock::time_point& last_update,
617 const std::chrono::system_clock::time_point& ,
618 cache::UpdateStatisticsScope& stats_scope
621 if constexpr (!kIncrementalUpdates) {
625 const std::chrono::milliseconds
630 UpdateData data{GetDataSnapshot(type)};
633 for (
auto& cluster : clusters_) {
634 const QueryParams params{
636 .command_control = pg::
CommandControl{timeout, pg_cache::detail::kStatementTimeoutOff},
637 .last_updated = GetLastUpdated(last_update, data.GetLatestData()),
639 changes += UpdateFromCluster(*cluster, params, data, stats_scope, scope);
644 if constexpr (pg_cache::detail::kIsContainerCopiedByElement<DataType>) {
645 if (
const auto copied_size = data.GetCopiedSize(); copied_size > 0) {
646 const auto elapsed_copy = scope
.ElapsedTotal(std::string{pg_cache::detail::kCopyStage}
);
647 if (elapsed_copy > pg_cache::detail::kCpuRelaxThreshold) {
648 cpu_relax_iterations_copy_ =
static_cast<std::size_t>(
649 static_cast<
double>(copied_size) / (elapsed_copy / pg_cache::detail::kCpuRelaxInterval)
652 <<
"Elapsed time for copying " << kName <<
" " << elapsed_copy.count() <<
" for " << changes
653 <<
" data items is over threshold. Will relax CPU every " << cpu_relax_iterations_parse_
660 const auto elapsed_parse = scope
.ElapsedTotal(std::string{pg_cache::detail::kParseStage}
);
661 if (elapsed_parse > pg_cache::detail::kCpuRelaxThreshold) {
662 cpu_relax_iterations_parse_ =
static_cast<
663 std::size_t>(
static_cast<
double>(changes) / (elapsed_parse / pg_cache::detail::kCpuRelaxInterval));
665 <<
"Elapsed time for parsing " << kName <<
" " << elapsed_parse.count() <<
" for " << changes
666 <<
" data items is over threshold. Will relax CPU every " << cpu_relax_iterations_parse_
671 auto data_cache = std::move(data).ReleaseNewData();
673 pg_cache::detail::OnWritesDone(*data_cache);
675 this->Set(std::move(data_cache));
681template <
typename PostgreCachePolicy>
682bool PostgreCache<PostgreCachePolicy>::MayReturnNull()
const {
683 return pg_cache::detail::MayReturnNull<PolicyType>();
686template <
typename PostgreCachePolicy>
687std::size_t PostgreCache<PostgreCachePolicy>::UpdateFromCluster(
689 const QueryParams& params,
691 cache::UpdateStatisticsScope& stats_scope,
694 scope
.Reset(std::string{pg_cache::detail::kFetchStage}
);
695 if (chunk_size_ == 0) {
696 auto res = FetchAll(cluster, params, stats_scope);
697 return CacheNonEmptyResults(std::move(res), data, stats_scope, scope);
699 if (data.NeedsCopy()) {
700 auto first_chunk = FetchFirstChunk(cluster, params);
701 if (first_chunk.is_complete) {
703 return CacheNonEmptyResults(std::move(first_chunk.result), data, stats_scope, scope);
705 GetOrCreateNewData(data, scope);
707 return CacheAllChunks(cluster, params, data, stats_scope, scope);
710template <
typename PostgreCachePolicy>
713 const QueryParams& params,
714 cache::UpdateStatisticsScope& stats_scope
716 const bool has_parameter = params.query.GetStatementView().find(
'$') != std::string::npos;
719 ? cluster.Execute(kClusterHostTypeFlags, params.command_control, params.query, params.last_updated)
720 : cluster.Execute(kClusterHostTypeFlags, params.command_control, params.query);
725template <
typename PostgreCachePolicy>
726typename PostgreCache<PostgreCachePolicy>::FirstChunk PostgreCache<
727 PostgreCachePolicy>::FetchFirstChunk(storages::
postgres::
Cluster& cluster,
const QueryParams& params) {
729 auto portal = trx.MakePortal(params.query, params.last_updated);
730 auto res = portal.Fetch(chunk_size_);
731 const bool is_complete = !portal;
734 .result = std::move(res),
735 .is_complete = is_complete,
739template <
typename PostgreCachePolicy>
740std::size_t PostgreCache<PostgreCachePolicy>::CacheAllChunks(
742 const QueryParams& params,
744 cache::UpdateStatisticsScope& stats_scope,
747 scope
.Reset(std::string{pg_cache::detail::kFetchStage}
);
749 auto portal = trx.MakePortal(params.query, params.last_updated);
750 std::size_t changes = 0;
752 scope
.Reset(std::string{pg_cache::detail::kFetchStage}
);
753 auto res = portal.Fetch(chunk_size_);
755 changes += CacheNonEmptyResults(std::move(res), data, stats_scope, scope);
756 if (sleep_between_chunks_.count() > 0) {
764template <
typename PostgreCachePolicy>
765std::size_t PostgreCache<PostgreCachePolicy>::CacheNonEmptyResults(
768 cache::UpdateStatisticsScope& stats_scope,
774 auto& data_cache = GetOrCreateNewData(data, scope);
775 scope
.Reset(std::string{pg_cache::detail::kParseStage}
);
777 CacheResults(std::move(res), data_cache, stats_scope, scope);
781template <
typename PostgreCachePolicy>
782void PostgreCache<PostgreCachePolicy>::CacheResults(
784 DataType& data_cache,
785 cache::UpdateStatisticsScope& stats_scope,
788 auto values = res.AsSetOf<RawValueType>(pg_cache::detail::GetTag<PostgreCachePolicy>());
790 for (
auto p = values.begin(); p != values.end(); ++p) {
793 using pg_cache::detail::CacheInsertOrAssign;
796 pg_cache::detail::ExtractValue<PostgreCachePolicy>(*p),
797 PostgreCachePolicy::kKeyMember
799 }
catch (
const std::exception& e) {
802 <<
"Error parsing data row in cache '" << kName <<
"' to '" <<
compiler::GetTypeName<ValueType>()
803 <<
"': " << e.what();
808template <
typename PostgreCachePolicy>
809utils::SharedReadablePtr<
typename PostgreCache<PostgreCachePolicy>::DataType> PostgreCache<
817template <
typename PostgreCachePolicy>
818typename PostgreCache<PostgreCachePolicy>::DataType& PostgreCache<
819 PostgreCachePolicy>::GetOrCreateNewData(UpdateData& data, tracing::
ScopeTime& scope) {
820 if (data.NeedsCopy()) {
821 scope
.Reset(std::string{pg_cache::detail::kCopyStage}
);
823 return data.GetOrCreateNewData(cpu_relax_iterations_copy_, scope);
828std::string GetPostgreCacheSchema();
832template <
typename PostgreCachePolicy>
833yaml_config::Schema PostgreCache<PostgreCachePolicy>::GetStaticConfigSchema() {
834 using ParentType =
typename pg_cache::detail::PolicyChecker<PostgreCachePolicy>::BaseType;
835 return yaml_config::MergeSchemas<ParentType>(impl::GetPostgreCacheSchema());
840namespace utils::impl::projected_set {
842template <
typename Set,
typename Value,
typename KeyMember>
843void CacheInsertOrAssign(Set& set, Value&& value,
const KeyMember& ) {
844 DoInsert(set, std::forward<Value>(value));