@@ -562,6 +562,23 @@ public Boolean copy(K source, K target, boolean replace) {
562
562
return doWithKeys (connection -> connection .copy (sourceKey , targetKey , replace ));
563
563
}
564
564
565
+ @ Override
566
+ public Boolean hasKey (K key ) {
567
+
568
+ byte [] rawKey = rawKey (key );
569
+
570
+ return doWithKeys (connection -> connection .exists (rawKey ));
571
+ }
572
+
573
+ @ Override
574
+ public Long countExistingKeys (Collection <K > keys ) {
575
+
576
+ Assert .notNull (keys , "Keys must not be null!" );
577
+
578
+ byte [][] rawKeys = rawKeys (keys );
579
+ return doWithKeys (connection -> connection .exists (rawKeys ));
580
+ }
581
+
565
582
@ Override
566
583
public Boolean delete (K key ) {
567
584
@@ -606,20 +623,56 @@ public Long unlink(Collection<K> keys) {
606
623
}
607
624
608
625
@ Override
609
- public Boolean hasKey (K key ) {
626
+ public DataType type (K key ) {
610
627
611
628
byte [] rawKey = rawKey (key );
629
+ return doWithKeys (connection -> connection .type (rawKey ));
630
+ }
612
631
613
- return doWithKeys (connection -> connection .exists (rawKey ));
632
+ @ Override
633
+ @ SuppressWarnings ("unchecked" )
634
+ public Set <K > keys (K pattern ) {
635
+
636
+ byte [] rawKey = rawKey (pattern );
637
+ Set <byte []> rawKeys = doWithKeys (connection -> connection .keys (rawKey ));
638
+
639
+ return keySerializer != null ? SerializationUtils .deserialize (rawKeys , keySerializer ) : (Set <K >) rawKeys ;
614
640
}
615
641
616
642
@ Override
617
- public Long countExistingKeys (Collection <K > keys ) {
643
+ public Cursor <K > scan (ScanOptions options ) {
644
+ Assert .notNull (options , "ScanOptions must not be null!" );
618
645
619
- Assert .notNull (keys , "Keys must not be null!" );
646
+ return executeWithStickyConnection (
647
+ (RedisCallback <Cursor <K >>) connection -> new ConvertingCursor <>(connection .scan (options ),
648
+ this ::deserializeKey ));
649
+ }
620
650
621
- byte [][] rawKeys = rawKeys (keys );
622
- return doWithKeys (connection -> connection .exists (rawKeys ));
651
+ @ Override
652
+ public K randomKey () {
653
+
654
+ byte [] rawKey = doWithKeys (RedisKeyCommands ::randomKey );
655
+ return deserializeKey (rawKey );
656
+ }
657
+
658
+ @ Override
659
+ public void rename (K oldKey , K newKey ) {
660
+
661
+ byte [] rawOldKey = rawKey (oldKey );
662
+ byte [] rawNewKey = rawKey (newKey );
663
+
664
+ doWithKeys (connection -> {
665
+ connection .rename (rawOldKey , rawNewKey );
666
+ return null ;
667
+ });
668
+ }
669
+
670
+ @ Override
671
+ public Boolean renameIfAbsent (K oldKey , K newKey ) {
672
+
673
+ byte [] rawOldKey = rawKey (oldKey );
674
+ byte [] rawNewKey = rawKey (newKey );
675
+ return doWithKeys (connection -> connection .renameNX (rawOldKey , rawNewKey ));
623
676
}
624
677
625
678
@ Override
@@ -652,9 +705,12 @@ public Boolean expireAt(K key, final Date date) {
652
705
});
653
706
}
654
707
655
- // -------------------------------------------------------------------------
656
- // Methods dealing with value operations
657
- // -------------------------------------------------------------------------
708
+ @ Override
709
+ public Boolean persist (K key ) {
710
+
711
+ byte [] rawKey = rawKey (key );
712
+ return doWithKeys (connection -> connection .persist (rawKey ));
713
+ }
658
714
659
715
@ Override
660
716
public Long getExpire (K key ) {
@@ -664,7 +720,7 @@ public Long getExpire(K key) {
664
720
}
665
721
666
722
@ Override
667
- public Long getExpire (K key , final TimeUnit timeUnit ) {
723
+ public Long getExpire (K key , TimeUnit timeUnit ) {
668
724
669
725
byte [] rawKey = rawKey (key );
670
726
return doWithKeys (connection -> {
@@ -677,73 +733,13 @@ public Long getExpire(K key, final TimeUnit timeUnit) {
677
733
});
678
734
}
679
735
680
- @ Override
681
- @ SuppressWarnings ("unchecked" )
682
- public Set <K > keys (K pattern ) {
683
-
684
- byte [] rawKey = rawKey (pattern );
685
- Set <byte []> rawKeys = doWithKeys (connection -> connection .keys (rawKey ));
686
-
687
- return keySerializer != null ? SerializationUtils .deserialize (rawKeys , keySerializer ) : (Set <K >) rawKeys ;
688
- }
689
-
690
- @ Override
691
- public Cursor <K > scan (ScanOptions options ) {
692
- Assert .notNull (options , "ScanOptions must not be null!" );
693
-
694
- return executeWithStickyConnection (
695
- (RedisCallback <Cursor <K >>) connection -> new ConvertingCursor <>(connection .scan (options ),
696
- this ::deserializeKey ));
697
- }
698
-
699
- @ Override
700
- public Boolean persist (K key ) {
701
-
702
- byte [] rawKey = rawKey (key );
703
- return doWithKeys (connection -> connection .persist (rawKey ));
704
- }
705
-
706
736
@ Override
707
737
public Boolean move (K key , final int dbIndex ) {
708
738
709
739
byte [] rawKey = rawKey (key );
710
740
return doWithKeys (connection -> connection .move (rawKey , dbIndex ));
711
741
}
712
742
713
- @ Override
714
- public K randomKey () {
715
-
716
- byte [] rawKey = doWithKeys (RedisKeyCommands ::randomKey );
717
- return deserializeKey (rawKey );
718
- }
719
-
720
- @ Override
721
- public void rename (K oldKey , K newKey ) {
722
-
723
- byte [] rawOldKey = rawKey (oldKey );
724
- byte [] rawNewKey = rawKey (newKey );
725
-
726
- doWithKeys (connection -> {
727
- connection .rename (rawOldKey , rawNewKey );
728
- return null ;
729
- });
730
- }
731
-
732
- @ Override
733
- public Boolean renameIfAbsent (K oldKey , K newKey ) {
734
-
735
- byte [] rawOldKey = rawKey (oldKey );
736
- byte [] rawNewKey = rawKey (newKey );
737
- return doWithKeys (connection -> connection .renameNX (rawOldKey , rawNewKey ));
738
- }
739
-
740
- @ Override
741
- public DataType type (K key ) {
742
-
743
- byte [] rawKey = rawKey (key );
744
- return doWithKeys (connection -> connection .type (rawKey ));
745
- }
746
-
747
743
/**
748
744
* Executes the Redis dump command and returns the results. Redis uses a non-standard serialization mechanism and
749
745
* includes checksum information, thus the raw bytes are returned as opposed to deserializing with valueSerializer.
0 commit comments