61 enum class Exist { kAddAlways, kAddIfNotExist, kAddIfExist };
62 enum class Compare { kNone, kGreaterThan, kLessThan };
63 enum class ReturnValue { kAddedCount, kChangedCount };
65 ZaddOptions() =
default;
66 constexpr ZaddOptions(
68 ReturnValue return_value = ReturnValue::kAddedCount,
69 Compare compare = Compare::kNone
73 return_value(return_value)
75 constexpr ZaddOptions(Exist exist, Compare compare, ReturnValue return_value = ReturnValue::kAddedCount)
78 return_value(return_value)
81 constexpr ZaddOptions(ReturnValue return_value, Exist exist = Exist::kAddAlways, Compare compare = Compare::kNone)
84 return_value(return_value)
86 constexpr ZaddOptions(ReturnValue return_value, Compare compare, Exist exist = Exist::kAddAlways)
89 return_value(return_value)
92 constexpr ZaddOptions(
94 Exist exist = Exist::kAddAlways,
95 ReturnValue return_value = ReturnValue::kAddedCount
99 return_value(return_value)
101 constexpr ZaddOptions(Compare compare, ReturnValue return_value, Exist exist = Exist::kAddAlways)
104 return_value(return_value)
107 Exist exist = Exist::kAddAlways;
108 Compare compare = Compare::kNone;
109 ReturnValue return_value = ReturnValue::kAddedCount;
159 using Match = storages::
redis::Match;
160 using Count = storages::
redis::Count;
162 ScanOptionsGeneric() =
default;
170 template <
typename... Args>
171 ScanOptionsGeneric(Args... args) {
172 (Apply(std::move(args)), ...);
175 const std::optional<Match>& GetMatchOptional()
const noexcept {
return pattern_; }
177 const std::optional<Count>& GetCountOptional()
const noexcept {
return count_; }
179 std::optional<Match> ExtractMatch()
noexcept {
return std::move(pattern_); }
181 std::optional<Count> ExtractCount()
noexcept {
return std::move(count_); }
184 void Apply(Match pattern) {
188 pattern_ = std::move(pattern);
191 void Apply(Count count) {
198 std::optional<Match> pattern_;
199 std::optional<Count> count_;
219 enum class Exist { kSetAlways, kSetIfNotExist, kSetIfExist };
220 enum class Compare { kNone, kGreaterThan, kLessThan };
222 ExpireOptions() =
default;
223 constexpr ExpireOptions(Exist exist, Compare compare = Compare::kNone)
227 if (exist == Exist::kSetIfNotExist && compare != Compare::kNone) {
229 throw std::invalid_argument(
"When exist is kSetIfNotExist, compare must be kNone");
233 constexpr ExpireOptions(Compare compare, Exist exist = Exist::kSetAlways)
237 if (exist == Exist::kSetIfNotExist && compare != Compare::kNone) {
239 throw std::invalid_argument(
"When exist is kSetIfNotExist, compare must be kNone");
243 Exist exist = Exist::kSetAlways;
244 Compare compare = Compare::kNone;