@@ -578,4 +578,83 @@ default Flux<Map.Entry<ByteBuffer, ByteBuffer>> hGetAll(ByteBuffer key) {
578
578
* @see <a href="http://redis.io/commands/hgetall">Redis Documentation: HGETALL</a>
579
579
*/
580
580
Flux <CommandResponse <KeyCommand , Flux <Map .Entry <ByteBuffer , ByteBuffer >>>> hGetAll (Publisher <KeyCommand > commands );
581
+
582
+ /**
583
+ * @author Christoph Strobl
584
+ * @see <a href="http://redis.io/commands/hstrlen">Redis Documentation: HSTRLEN</a>
585
+ * @since 2.1
586
+ */
587
+ class HStrLenCommand extends KeyCommand {
588
+
589
+ private ByteBuffer field ;
590
+
591
+ /**
592
+ * Creates a new {@link HStrLenCommand} given a {@code key}.
593
+ *
594
+ * @param key can be {@literal null}.
595
+ * @param field must not be {@literal null}.
596
+ */
597
+ private HStrLenCommand (@ Nullable ByteBuffer key , ByteBuffer field ) {
598
+
599
+ super (key );
600
+ this .field = field ;
601
+ }
602
+
603
+ /**
604
+ * Specify the {@code field} within the hash to get the length of the {@code value} of.ø
605
+ *
606
+ * @param field must not be {@literal null}.
607
+ * @return new instance of {@link HStrLenCommand}.
608
+ */
609
+ public static HStrLenCommand lengthOf (ByteBuffer field ) {
610
+
611
+ Assert .notNull (field , "Field must not be null!" );
612
+ return new HStrLenCommand (null , field );
613
+ }
614
+
615
+ /**
616
+ * Define the {@code key} the hash is stored at.
617
+ *
618
+ * @param key must not be {@literal null}.
619
+ * @return new instance of {@link HStrLenCommand}.
620
+ */
621
+ public HStrLenCommand from (ByteBuffer key ) {
622
+ return new HStrLenCommand (key , field );
623
+ }
624
+
625
+ /**
626
+ * @return {@literal null} if not already set.
627
+ */
628
+ @ Nullable
629
+ public ByteBuffer getField () {
630
+ return field ;
631
+ }
632
+ }
633
+
634
+ /**
635
+ * Get the length of the value associated with {@code hashKey}. If either the {@code key} or the {@code hashKey} do
636
+ * not exist, {@code 0} is emitted.
637
+ *
638
+ * @param key must not be {@literal null}.
639
+ * @param field must not be {@literal null}.
640
+ * @return never {@literal null}.
641
+ * @since 2.1
642
+ */
643
+ default Mono <Long > hStrLen (ByteBuffer key , ByteBuffer field ) {
644
+
645
+ Assert .notNull (key , "Key must not be null!" );
646
+ Assert .notNull (field , "Field must not be null!" );
647
+
648
+ return hStrLen (Mono .just (HStrLenCommand .lengthOf (field ).from (key ))).next ().map (NumericResponse ::getOutput );
649
+ }
650
+
651
+ /**
652
+ * Get the length of the value associated with {@code hashKey}. If either the {@code key} or the {@code hashKey} do
653
+ * not exist, {@code 0} is emitted.
654
+ *
655
+ * @param commands must not be {@literal null}.
656
+ * @return never {@literal null}.
657
+ * @since 2.1
658
+ */
659
+ Flux <NumericResponse <HStrLenCommand , Long >> hStrLen (Publisher <HStrLenCommand > commands );
581
660
}
0 commit comments