|
32 | 32 | import org.springframework.data.redis.connection.ReactiveRedisConnection.CommandResponse;
|
33 | 33 | import org.springframework.data.redis.connection.ReactiveRedisConnection.KeyCommand;
|
34 | 34 | import org.springframework.data.redis.connection.ReactiveRedisConnection.KeyScanCommand;
|
| 35 | +import org.springframework.data.redis.connection.ReactiveRedisConnection.MultiValueResponse; |
35 | 36 | import org.springframework.data.redis.connection.ReactiveRedisConnection.NumericResponse;
|
36 | 37 | import org.springframework.data.redis.core.ScanOptions;
|
37 | 38 | import org.springframework.lang.Nullable;
|
@@ -546,14 +547,94 @@ default Mono<Boolean> sIsMember(ByteBuffer key, ByteBuffer value) {
|
546 | 547 | }
|
547 | 548 |
|
548 | 549 | /**
|
549 |
| - * Check if set at {@link SIsMemberCommand#getKey()} contains {@link SIsMemberCommand#getKey()}. |
| 550 | + * Check if set at {@link SIsMemberCommand#getKey()} contains {@link SIsMemberCommand#getValue()}. |
550 | 551 | *
|
551 | 552 | * @param commands must not be {@literal null}.
|
552 | 553 | * @return
|
553 | 554 | * @see <a href="https://redis.io/commands/sismember">Redis Documentation: SISMEMBER</a>
|
554 | 555 | */
|
555 | 556 | Flux<BooleanResponse<SIsMemberCommand>> sIsMember(Publisher<SIsMemberCommand> commands);
|
556 | 557 |
|
| 558 | + /** |
| 559 | + * {@code SMISMEMBER} command parameters. |
| 560 | + * |
| 561 | + * @author Mark Paluch |
| 562 | + * @since 2.6 |
| 563 | + * @see <a href="https://redis.io/commands/smismember">Redis Documentation: SMISMEMBER</a> |
| 564 | + */ |
| 565 | + class SMIsMemberCommand extends KeyCommand { |
| 566 | + |
| 567 | + private final List<ByteBuffer> values; |
| 568 | + |
| 569 | + private SMIsMemberCommand(@Nullable ByteBuffer key, List<ByteBuffer> values) { |
| 570 | + |
| 571 | + super(key); |
| 572 | + |
| 573 | + this.values = values; |
| 574 | + } |
| 575 | + |
| 576 | + /** |
| 577 | + * Creates a new {@link SMIsMemberCommand} given one or more {@literal values}. |
| 578 | + * |
| 579 | + * @param value must not be {@literal null}. |
| 580 | + * @return a new {@link SMIsMemberCommand} for a {@literal value}. |
| 581 | + */ |
| 582 | + public static SMIsMemberCommand values(List<ByteBuffer> values) { |
| 583 | + |
| 584 | + Assert.notNull(values, "Values must not be null!"); |
| 585 | + Assert.notEmpty(values, "Values must not be empty!"); |
| 586 | + |
| 587 | + return new SMIsMemberCommand(null, values); |
| 588 | + } |
| 589 | + |
| 590 | + /** |
| 591 | + * Applies the {@literal set} key. Constructs a new command instance with all previously configured properties. |
| 592 | + * |
| 593 | + * @param set must not be {@literal null}. |
| 594 | + * @return a new {@link SMIsMemberCommand} with {@literal set} applied. |
| 595 | + */ |
| 596 | + public SMIsMemberCommand of(ByteBuffer set) { |
| 597 | + |
| 598 | + Assert.notNull(set, "Set key must not be null!"); |
| 599 | + |
| 600 | + return new SMIsMemberCommand(set, values); |
| 601 | + } |
| 602 | + |
| 603 | + /** |
| 604 | + * @return |
| 605 | + */ |
| 606 | + public List<ByteBuffer> getValues() { |
| 607 | + return values; |
| 608 | + } |
| 609 | + } |
| 610 | + |
| 611 | + /** |
| 612 | + * Check if set at {@code key} contains one or more {@code values}. |
| 613 | + * |
| 614 | + * @param key must not be {@literal null}. |
| 615 | + * @param values must not be {@literal null}. |
| 616 | + * @return {@literal null} when used in pipeline / transaction. |
| 617 | + * @since 2.6 |
| 618 | + * @see <a href="https://redis.io/commands/smismember">Redis Documentation: SMISMEMBER</a> |
| 619 | + */ |
| 620 | + default Mono<List<Boolean>> sMIsMember(ByteBuffer key, List<ByteBuffer> values) { |
| 621 | + |
| 622 | + Assert.notNull(key, "Key must not be null!"); |
| 623 | + Assert.notNull(values, "Value must not be null!"); |
| 624 | + |
| 625 | + return sMIsMember(Mono.just(SMIsMemberCommand.values(values).of(key))).next().map(MultiValueResponse::getOutput); |
| 626 | + } |
| 627 | + |
| 628 | + /** |
| 629 | + * Check if set at {@link SMIsMemberCommand#getKey()} contains {@link SMIsMemberCommand#getValues()}. |
| 630 | + * |
| 631 | + * @param commands must not be {@literal null}. |
| 632 | + * @return |
| 633 | + * @since 2.6 |
| 634 | + * @see <a href="https://redis.io/commands/smismember">Redis Documentation: SMISMEMBER</a> |
| 635 | + */ |
| 636 | + Flux<MultiValueResponse<SMIsMemberCommand, Boolean>> sMIsMember(Publisher<SMIsMemberCommand> commands); |
| 637 | + |
557 | 638 | /**
|
558 | 639 | * {@code SINTER} command parameters.
|
559 | 640 | *
|
|
0 commit comments