108 enum class Exist { kAddAlways, kAddIfNotExist, kAddIfExist };
109 enum class Compare { kNone, kGreaterThan, kLessThan };
110 enum class ReturnValue { kAddedCount, kChangedCount };
112 ZaddOptions() =
default;
113 constexpr ZaddOptions(
115 ReturnValue return_value = ReturnValue::kAddedCount,
116 Compare compare = Compare::kNone
120 return_value(return_value)
122 constexpr ZaddOptions(Exist exist, Compare compare, ReturnValue return_value = ReturnValue::kAddedCount)
125 return_value(return_value)
128 constexpr ZaddOptions(ReturnValue return_value, Exist exist = Exist::kAddAlways, Compare compare = Compare::kNone)
131 return_value(return_value)
133 constexpr ZaddOptions(ReturnValue return_value, Compare compare, Exist exist = Exist::kAddAlways)
136 return_value(return_value)
139 constexpr ZaddOptions(
141 Exist exist = Exist::kAddAlways,
142 ReturnValue return_value = ReturnValue::kAddedCount
146 return_value(return_value)
148 constexpr ZaddOptions(Compare compare, ReturnValue return_value, Exist exist = Exist::kAddAlways)
151 return_value(return_value)
154 Exist exist = Exist::kAddAlways;
155 Compare compare = Compare::kNone;
156 ReturnValue return_value = ReturnValue::kAddedCount;
204class ScanOptionsGeneric {
209 ScanOptionsGeneric() =
default;
211 ScanOptionsGeneric(
const ScanOptionsGeneric& other) =
default;
212 ScanOptionsGeneric& operator=(
const ScanOptionsGeneric& other) =
default;
214 ScanOptionsGeneric(ScanOptionsGeneric&& other) =
default;
215 ScanOptionsGeneric& operator=(ScanOptionsGeneric&& other) =
default;
217 template <
typename... Args>
218 ScanOptionsGeneric(Args... args) {
219 (Apply(std::move(args)), ...);
222 const std::optional<Match>& GetMatchOptional()
const noexcept {
return pattern_; }
224 const std::optional<Count>& GetCountOptional()
const noexcept {
return count_; }
226 std::optional<Match> ExtractMatch()
noexcept {
return std::move(pattern_); }
228 std::optional<Count> ExtractCount()
noexcept {
return std::move(count_); }
231 void Apply(Match pattern) {
235 pattern_ = std::move(pattern);
238 void Apply(Count count) {
245 std::optional<Match> pattern_;
246 std::optional<Count> count_;
329struct ExpireOptions {
330 enum class Exist { kSetAlways, kSetIfNotExist, kSetIfExist };
331 enum class Compare { kNone, kGreaterThan, kLessThan };
333 ExpireOptions() =
default;
334 constexpr ExpireOptions(Exist exist, Compare compare = Compare::kNone)
338 if (exist == Exist::kSetIfNotExist && compare != Compare::kNone) {
340 throw std::invalid_argument(
"When exist is kSetIfNotExist, compare must be kNone");
344 constexpr ExpireOptions(Compare compare, Exist exist = Exist::kSetAlways)
348 if (exist == Exist::kSetIfNotExist && compare != Compare::kNone) {
350 throw std::invalid_argument(
"When exist is kSetIfNotExist, compare must be kNone");
354 Exist exist = Exist::kSetAlways;
355 Compare compare = Compare::kNone;