60 enum class Exist { kAddAlways, kAddIfNotExist, kAddIfExist };
61 enum class Compare { kNone, kGreaterThan, kLessThan };
62 enum class ReturnValue { kAddedCount, kChangedCount };
64 ZaddOptions() =
default;
65 constexpr ZaddOptions(
67 ReturnValue return_value = ReturnValue::kAddedCount,
68 Compare compare = Compare::kNone
72 return_value(return_value)
74 constexpr ZaddOptions(Exist exist, Compare compare, ReturnValue return_value = ReturnValue::kAddedCount)
77 return_value(return_value)
80 constexpr ZaddOptions(ReturnValue return_value, Exist exist = Exist::kAddAlways, Compare compare = Compare::kNone)
83 return_value(return_value)
85 constexpr ZaddOptions(ReturnValue return_value, Compare compare, Exist exist = Exist::kAddAlways)
88 return_value(return_value)
91 constexpr ZaddOptions(
93 Exist exist = Exist::kAddAlways,
94 ReturnValue return_value = ReturnValue::kAddedCount
98 return_value(return_value)
100 constexpr ZaddOptions(Compare compare, ReturnValue return_value, Exist exist = Exist::kAddAlways)
103 return_value(return_value)
106 Exist exist = Exist::kAddAlways;
107 Compare compare = Compare::kNone;
108 ReturnValue return_value = ReturnValue::kAddedCount;
158 using Match = storages::
redis::Match;
159 using Count = storages::
redis::Count;
161 ScanOptionsGeneric() =
default;
169 template <
typename... Args>
170 ScanOptionsGeneric(Args... args) {
171 (Apply(std::move(args)), ...);
174 const std::optional<Match>& GetMatchOptional()
const noexcept {
return pattern_; }
176 const std::optional<Count>& GetCountOptional()
const noexcept {
return count_; }
178 std::optional<Match> ExtractMatch()
noexcept {
return std::move(pattern_); }
180 std::optional<Count> ExtractCount()
noexcept {
return std::move(count_); }
183 void Apply(Match pattern) {
187 pattern_ = std::move(pattern);
190 void Apply(Count count) {
197 std::optional<Match> pattern_;
198 std::optional<Count> count_;
218 enum class Exist { kSetAlways, kSetIfNotExist, kSetIfExist };
219 enum class Compare { kNone, kGreaterThan, kLessThan };
221 ExpireOptions() =
default;
222 constexpr ExpireOptions(Exist exist, Compare compare = Compare::kNone)
226 if (exist == Exist::kSetIfNotExist && compare != Compare::kNone) {
228 throw std::invalid_argument(
"When exist is kSetIfNotExist, compare must be kNone");
232 constexpr ExpireOptions(Compare compare, Exist exist = Exist::kSetAlways)
236 if (exist == Exist::kSetIfNotExist && compare != Compare::kNone) {
238 throw std::invalid_argument(
"When exist is kSetIfNotExist, compare must be kNone");
242 Exist exist = Exist::kSetAlways;
243 Compare compare = Compare::kNone;