@@ -31,21 +31,21 @@ public void opsValue() {
31
31
ReactiveValueOperations <String , String > valueOps = reactiveRedisTemplate .opsForValue ();
32
32
Set <String > cacheKeys = new HashSet <>();
33
33
Map <String , String > setDatas = new HashMap <>();
34
- for (int i = 0 ; i < 100 ; i ++) {
34
+ for (int i = 0 ; i < 10 ; i ++) {
35
35
String key = "value_" + i ;
36
36
cacheKeys .add (key );
37
37
setDatas .put (key , String .valueOf (i ));
38
38
}
39
- // previous key delete - sync
39
+ // previous key delete - sync process
40
40
redisTemplate .delete (cacheKeys );
41
41
42
- // async
42
+ // async process
43
43
Mono <Boolean > results = valueOps .multiSet (setDatas );
44
44
StepVerifier .create (results ).expectNext (true ).verifyComplete ();
45
45
46
46
Mono <List <String >> values = valueOps .multiGet (cacheKeys );
47
47
StepVerifier .create (values )
48
- .expectNextMatches (x -> x .size () == 100 ).verifyComplete ();
48
+ .expectNextMatches (x -> x .size () == 10 ).verifyComplete ();
49
49
}
50
50
51
51
/**
@@ -56,10 +56,10 @@ public void opsList() {
56
56
ReactiveListOperations <String , String > listOps = reactiveRedisTemplate .opsForList ();
57
57
String cacheKey = "valueList" ;
58
58
59
- // previous key delete
59
+ // previous key delete - sync process
60
60
redisTemplate .delete (cacheKey );
61
61
62
- // async
62
+ // async process
63
63
Mono <Long > results = listOps .leftPushAll (cacheKey , "0" , "1" , "2" , "3" , "4" , "5" , "6" , "7" , "8" , "9" );
64
64
StepVerifier .create (results ).expectNext (10L ).verifyComplete ();
65
65
StepVerifier .create (reactiveRedisTemplate .type (cacheKey )).expectNext (DataType .LIST ).verifyComplete ();
@@ -83,7 +83,7 @@ public void opsHash() {
83
83
// previous key delete - sync
84
84
redisTemplate .delete (cacheKey );
85
85
86
- // async
86
+ // async process
87
87
StepVerifier .create (hashOps .putAll (cacheKey , setDatas )).expectNext (true ).verifyComplete ();
88
88
StepVerifier .create (reactiveRedisTemplate .type (cacheKey )).expectNext (DataType .HASH ).verifyComplete ();
89
89
StepVerifier .create (hashOps .size (cacheKey )).expectNext (10L ).verifyComplete ();
@@ -99,13 +99,11 @@ public void opsSet() {
99
99
ReactiveSetOperations <String , String > setOps = reactiveRedisTemplate .opsForSet ();
100
100
String cacheKey = "valueSet" ;
101
101
102
- // previous key delete - sync
102
+ // previous key delete - sync process
103
103
redisTemplate .delete (cacheKey );
104
104
105
- // async
106
- for (int i = 0 ; i < 10 ; i ++)
107
- StepVerifier .create (setOps .add (cacheKey , String .valueOf (i ))).expectNext (1L ).verifyComplete ();
108
-
105
+ // async process
106
+ StepVerifier .create (setOps .add (cacheKey , "0" , "1" , "2" , "3" , "4" , "5" , "6" , "7" , "8" , "9" )).expectNext (10L ).verifyComplete ();
109
107
StepVerifier .create (reactiveRedisTemplate .type (cacheKey )).expectNext (DataType .SET ).verifyComplete ();
110
108
StepVerifier .create (setOps .size (cacheKey )).expectNext (10L ).verifyComplete ();
111
109
StepVerifier .create (setOps .isMember (cacheKey , "5" )).expectNext (true ).verifyComplete ();
@@ -119,13 +117,15 @@ public void opsSortedSet() {
119
117
ReactiveZSetOperations <String , String > zsetOps = reactiveRedisTemplate .opsForZSet ();
120
118
String cacheKey = "valueZSet" ;
121
119
122
- // previous key delete - sync
120
+ // previous key delete - sync process
123
121
redisTemplate .delete (cacheKey );
124
122
125
- // async
126
- for (int i = 0 ; i < 10 ; i ++)
127
- StepVerifier .create (zsetOps .add (cacheKey , String .valueOf (i ), i )).expectNext (true ).verifyComplete ();
128
-
123
+ // async process
124
+ List <ZSetOperations .TypedTuple <String >> tuples = new ArrayList <>();
125
+ for (int i = 0 ; i < 10 ; i ++) {
126
+ tuples .add (new DefaultTypedTuple <>(String .valueOf (i ), (double ) i ));
127
+ }
128
+ StepVerifier .create (zsetOps .addAll (cacheKey , tuples )).expectNext (10L ).verifyComplete ();
129
129
StepVerifier .create (reactiveRedisTemplate .type (cacheKey )).expectNext (DataType .ZSET ).verifyComplete ();
130
130
StepVerifier .create (zsetOps .size (cacheKey )).expectNext (10L ).verifyComplete ();
131
131
StepVerifier .create (zsetOps .reverseRank (cacheKey , "9" )).expectNext (0L ).verifyComplete ();
@@ -139,21 +139,22 @@ public void opsGeo() {
139
139
ReactiveGeoOperations <String , String > geoOps = reactiveRedisTemplate .opsForGeo ();
140
140
String [] cities = {"서울" , "부산" };
141
141
String [][] gu = {{"강남구" , "서초구" , "관악구" , "동작구" , "마포구" }, {"사하구" , "해운대구" , "영도구" , "동래구" , "수영구" }};
142
+ Point [][] pointGu = {{new Point (10 , -10 ), new Point (11 , -20 ), new Point (13 , 10 ), new Point (14 , 30 ), new Point (15 , 40 )}, {new Point (-100 , 10 ), new Point (-110 , 20 ), new Point (-130 , 80 ), new Point (-140 , 60 ), new Point (-150 , 30 )}};
142
143
String cacheKey = "valueGeo" ;
143
144
144
- // previous key delete - sync
145
+ // previous key delete - sync process
145
146
redisTemplate .delete (cacheKey );
146
147
148
+ // async process
147
149
Map <String , Point > memberCoordiateMap = new HashMap <>();
148
150
for (int x = 0 ; x < cities .length ; x ++) {
149
151
for (int y = 0 ; y < 5 ; y ++) {
150
- memberCoordiateMap .put (gu [x ][y ], new Point ( x , y ) );
152
+ memberCoordiateMap .put (gu [x ][y ], pointGu [ x ][ y ] );
151
153
}
152
154
}
153
- // async
154
155
StepVerifier .create (geoOps .add (cacheKey , memberCoordiateMap )).expectNext (10L ).verifyComplete ();
155
- StepVerifier .create (geoOps .distance (cacheKey , "강남구" , "동작구" )).expectNextMatches (x -> x .getValue () == 333678.8605 ).verifyComplete ();
156
- StepVerifier .create (geoOps .position (cacheKey , "동작구" )).expectNextMatches (x -> x .getX () == 0.000003 && x .getY () == 3.000001 ).verifyComplete ();
156
+ StepVerifier .create (geoOps .distance (cacheKey , "강남구" , "동작구" )).expectNextMatches (x -> x .getValue () == 4469610.0767 ).verifyComplete ();
157
+ StepVerifier .create (geoOps .position (cacheKey , "동작구" )).expectNextMatches (x -> x .getX () == 14.000001847743988 && x .getY () == 30.000000249977013 ).verifyComplete ();
157
158
}
158
159
159
160
/**
@@ -164,10 +165,10 @@ public void opsHyperLogLog() {
164
165
ReactiveHyperLogLogOperations <String , String > hyperLogLogOps = reactiveRedisTemplate .opsForHyperLogLog ();
165
166
String cacheKey = "valueHyperLogLog" ;
166
167
167
- // previous key delete - sync
168
+ // previous key delete - sync process
168
169
redisTemplate .delete (cacheKey );
169
170
170
- // async
171
+ // async process
171
172
String [] arr = {"1" , "2" , "2" , "3" , "4" , "5" , "5" , "5" , "5" , "6" , "7" , "7" , "7" };
172
173
StepVerifier .create (hyperLogLogOps .add (cacheKey , arr )).expectNext (1L ).verifyComplete ();
173
174
StepVerifier .create (hyperLogLogOps .size (cacheKey )).expectNext (7L ).verifyComplete ();
0 commit comments