@@ -69,6 +69,14 @@ public class ReactiveRedisTemplate<K, V> implements ReactiveRedisOperations<K, V
69
69
private final RedisSerializationContext <K , V > serializationContext ;
70
70
private final boolean exposeConnection ;
71
71
private final ReactiveScriptExecutor <K > reactiveScriptExecutor ;
72
+ private final ReactiveGeoOperations <K , V > geoOps ;
73
+ private final ReactiveHashOperations <K , ?, ?> hashOps ;
74
+ private final ReactiveHyperLogLogOperations <K , V > hllOps ;
75
+ private final ReactiveListOperations <K , V > listOps ;
76
+ private final ReactiveSetOperations <K , V > setOps ;
77
+ private final ReactiveStreamOperations <K , ?, ?> streamOps ;
78
+ private final ReactiveValueOperations <K , V > valueOps ;
79
+ private final ReactiveZSetOperations <K , V > zsetOps ;
72
80
73
81
/**
74
82
* Creates new {@link ReactiveRedisTemplate} using given {@link ReactiveRedisConnectionFactory} and
@@ -100,6 +108,15 @@ public ReactiveRedisTemplate(ReactiveRedisConnectionFactory connectionFactory,
100
108
this .serializationContext = serializationContext ;
101
109
this .exposeConnection = exposeConnection ;
102
110
this .reactiveScriptExecutor = new DefaultReactiveScriptExecutor <>(connectionFactory , serializationContext );
111
+
112
+ this .geoOps = opsForGeo (serializationContext );
113
+ this .hashOps = opsForHash (serializationContext );
114
+ this .hllOps = opsForHyperLogLog (serializationContext );
115
+ this .listOps = opsForList (serializationContext );
116
+ this .setOps = opsForSet (serializationContext );
117
+ this .streamOps = opsForStream (serializationContext );
118
+ this .valueOps = opsForValue (serializationContext );
119
+ this .zsetOps = opsForZSet (serializationContext );
103
120
}
104
121
105
122
/**
@@ -343,7 +360,7 @@ public Mono<Long> delete(Publisher<K> keys) {
343
360
return createFlux (connection -> connection .keyCommands () //
344
361
.mDel (Flux .from (keys ).map (this ::rawKey ).buffer (128 )) //
345
362
.map (CommandResponse ::getOutput )) //
346
- .collect (Collectors .summingLong (value -> value ));
363
+ .collect (Collectors .summingLong (value -> value ));
347
364
}
348
365
349
366
/*
@@ -378,7 +395,7 @@ public Mono<Long> unlink(Publisher<K> keys) {
378
395
return createFlux (connection -> connection .keyCommands () //
379
396
.mUnlink (Flux .from (keys ).map (this ::rawKey ).buffer (128 )) //
380
397
.map (CommandResponse ::getOutput )) //
381
- .collect (Collectors .summingLong (value -> value ));
398
+ .collect (Collectors .summingLong (value -> value ));
382
399
}
383
400
384
401
/*
@@ -530,7 +547,7 @@ protected ReactiveRedisConnection createRedisConnectionProxy(ReactiveRedisConnec
530
547
*/
531
548
@ Override
532
549
public ReactiveGeoOperations <K , V > opsForGeo () {
533
- return opsForGeo ( serializationContext ) ;
550
+ return geoOps ;
534
551
}
535
552
536
553
/*
@@ -547,8 +564,9 @@ public <K1, V1> ReactiveGeoOperations<K1, V1> opsForGeo(RedisSerializationContex
547
564
* @see org.springframework.data.redis.core.ReactiveRedisOperations#opsForHash()
548
565
*/
549
566
@ Override
567
+ @ SuppressWarnings ("unchecked" )
550
568
public <HK , HV > ReactiveHashOperations <K , HK , HV > opsForHash () {
551
- return opsForHash ( serializationContext ) ;
569
+ return ( ReactiveHashOperations < K , HK , HV >) hashOps ;
552
570
}
553
571
554
572
/*
@@ -567,7 +585,7 @@ public <K1, HK, HV> ReactiveHashOperations<K1, HK, HV> opsForHash(
567
585
*/
568
586
@ Override
569
587
public ReactiveHyperLogLogOperations <K , V > opsForHyperLogLog () {
570
- return opsForHyperLogLog ( serializationContext ) ;
588
+ return hllOps ;
571
589
}
572
590
573
591
/*
@@ -586,7 +604,7 @@ public <K1, V1> ReactiveHyperLogLogOperations<K1, V1> opsForHyperLogLog(
586
604
*/
587
605
@ Override
588
606
public ReactiveListOperations <K , V > opsForList () {
589
- return opsForList ( serializationContext ) ;
607
+ return listOps ;
590
608
}
591
609
592
610
/*
@@ -604,7 +622,7 @@ public <K1, V1> ReactiveListOperations<K1, V1> opsForList(RedisSerializationCont
604
622
*/
605
623
@ Override
606
624
public ReactiveSetOperations <K , V > opsForSet () {
607
- return opsForSet ( serializationContext ) ;
625
+ return setOps ;
608
626
}
609
627
610
628
/*
@@ -621,16 +639,18 @@ public <K1, V1> ReactiveSetOperations<K1, V1> opsForSet(RedisSerializationContex
621
639
* @see org.springframework.data.redis.core.ReactiveRedisOperations#opsForStream()
622
640
*/
623
641
@ Override
642
+ @ SuppressWarnings ("unchecked" )
624
643
public <HK , HV > ReactiveStreamOperations <K , HK , HV > opsForStream () {
625
- return opsForStream ( serializationContext ) ;
644
+ return ( ReactiveStreamOperations < K , HK , HV >) streamOps ;
626
645
}
627
646
628
647
/*
629
648
* (non-Javadoc)
630
649
* @see org.springframework.data.redis.core.ReactiveRedisOperations#opsForStream(HashMapper)
631
650
*/
632
651
@ Override
633
- public <HK , HV > ReactiveStreamOperations <K , HK , HV > opsForStream (HashMapper <? super K , ? super HK , ? super HV > hashMapper ) {
652
+ public <HK , HV > ReactiveStreamOperations <K , HK , HV > opsForStream (
653
+ HashMapper <? super K , ? super HK , ? super HV > hashMapper ) {
634
654
return opsForStream (serializationContext , hashMapper );
635
655
}
636
656
@@ -645,7 +665,8 @@ public <HK, HV> ReactiveStreamOperations<K, HK, HV> opsForStream(
645
665
}
646
666
647
667
protected <HK , HV > ReactiveStreamOperations <K , HK , HV > opsForStream (
648
- RedisSerializationContext <K , ?> serializationContext , @ Nullable HashMapper <? super K , ? super HK , ? super HV > hashMapper ) {
668
+ RedisSerializationContext <K , ?> serializationContext ,
669
+ @ Nullable HashMapper <? super K , ? super HK , ? super HV > hashMapper ) {
649
670
return new DefaultReactiveStreamOperations <>(this , serializationContext , hashMapper );
650
671
}
651
672
@@ -655,7 +676,7 @@ protected <HK, HV> ReactiveStreamOperations<K, HK, HV> opsForStream(
655
676
*/
656
677
@ Override
657
678
public ReactiveValueOperations <K , V > opsForValue () {
658
- return opsForValue ( serializationContext ) ;
679
+ return valueOps ;
659
680
}
660
681
661
682
/*
@@ -673,7 +694,7 @@ public <K1, V1> ReactiveValueOperations<K1, V1> opsForValue(RedisSerializationCo
673
694
*/
674
695
@ Override
675
696
public ReactiveZSetOperations <K , V > opsForZSet () {
676
- return opsForZSet ( serializationContext ) ;
697
+ return zsetOps ;
677
698
}
678
699
679
700
/*
0 commit comments