Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 9af76a9

Browse files
author
kimyonghwa
committed
reactive redis test
1 parent ce01ea5 commit 9af76a9

File tree

1 file changed

+25
-24
lines changed

1 file changed

+25
-24
lines changed

‎src/test/java/com/redis/cluster/ReactiveRedisClusterTest.java‎

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -31,21 +31,21 @@ public void opsValue() {
3131
ReactiveValueOperations<String, String> valueOps = reactiveRedisTemplate.opsForValue();
3232
Set<String> cacheKeys = new HashSet<>();
3333
Map<String, String> setDatas = new HashMap<>();
34-
for (int i = 0; i < 100; i++) {
34+
for (int i = 0; i < 10; i++) {
3535
String key = "value_" + i;
3636
cacheKeys.add(key);
3737
setDatas.put(key, String.valueOf(i));
3838
}
39-
// previous key delete - sync
39+
// previous key delete - sync process
4040
redisTemplate.delete(cacheKeys);
4141

42-
// async
42+
// async process
4343
Mono<Boolean> results = valueOps.multiSet(setDatas);
4444
StepVerifier.create(results).expectNext(true).verifyComplete();
4545

4646
Mono<List<String>> values = valueOps.multiGet(cacheKeys);
4747
StepVerifier.create(values)
48-
.expectNextMatches(x -> x.size() == 100).verifyComplete();
48+
.expectNextMatches(x -> x.size() == 10).verifyComplete();
4949
}
5050

5151
/**
@@ -56,10 +56,10 @@ public void opsList() {
5656
ReactiveListOperations<String, String> listOps = reactiveRedisTemplate.opsForList();
5757
String cacheKey = "valueList";
5858

59-
// previous key delete
59+
// previous key delete - sync process
6060
redisTemplate.delete(cacheKey);
6161

62-
// async
62+
// async process
6363
Mono<Long> results = listOps.leftPushAll(cacheKey, "0", "1", "2", "3", "4", "5", "6", "7", "8", "9");
6464
StepVerifier.create(results).expectNext(10L).verifyComplete();
6565
StepVerifier.create(reactiveRedisTemplate.type(cacheKey)).expectNext(DataType.LIST).verifyComplete();
@@ -83,7 +83,7 @@ public void opsHash() {
8383
// previous key delete - sync
8484
redisTemplate.delete(cacheKey);
8585

86-
// async
86+
// async process
8787
StepVerifier.create(hashOps.putAll(cacheKey, setDatas)).expectNext(true).verifyComplete();
8888
StepVerifier.create(reactiveRedisTemplate.type(cacheKey)).expectNext(DataType.HASH).verifyComplete();
8989
StepVerifier.create(hashOps.size(cacheKey)).expectNext(10L).verifyComplete();
@@ -99,13 +99,11 @@ public void opsSet() {
9999
ReactiveSetOperations<String, String> setOps = reactiveRedisTemplate.opsForSet();
100100
String cacheKey = "valueSet";
101101

102-
// previous key delete - sync
102+
// previous key delete - sync process
103103
redisTemplate.delete(cacheKey);
104104

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();
109107
StepVerifier.create(reactiveRedisTemplate.type(cacheKey)).expectNext(DataType.SET).verifyComplete();
110108
StepVerifier.create(setOps.size(cacheKey)).expectNext(10L).verifyComplete();
111109
StepVerifier.create(setOps.isMember(cacheKey, "5")).expectNext(true).verifyComplete();
@@ -119,13 +117,15 @@ public void opsSortedSet() {
119117
ReactiveZSetOperations<String, String> zsetOps = reactiveRedisTemplate.opsForZSet();
120118
String cacheKey = "valueZSet";
121119

122-
// previous key delete - sync
120+
// previous key delete - sync process
123121
redisTemplate.delete(cacheKey);
124122

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();
129129
StepVerifier.create(reactiveRedisTemplate.type(cacheKey)).expectNext(DataType.ZSET).verifyComplete();
130130
StepVerifier.create(zsetOps.size(cacheKey)).expectNext(10L).verifyComplete();
131131
StepVerifier.create(zsetOps.reverseRank(cacheKey, "9")).expectNext(0L).verifyComplete();
@@ -139,21 +139,22 @@ public void opsGeo() {
139139
ReactiveGeoOperations<String, String> geoOps = reactiveRedisTemplate.opsForGeo();
140140
String[] cities = {"서울", "부산"};
141141
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)}};
142143
String cacheKey = "valueGeo";
143144

144-
// previous key delete - sync
145+
// previous key delete - sync process
145146
redisTemplate.delete(cacheKey);
146147

148+
// async process
147149
Map<String, Point> memberCoordiateMap = new HashMap<>();
148150
for (int x = 0; x < cities.length; x++) {
149151
for (int y = 0; y < 5; y++) {
150-
memberCoordiateMap.put(gu[x][y], newPoint(x, y));
152+
memberCoordiateMap.put(gu[x][y], pointGu[x][y]);
151153
}
152154
}
153-
// async
154155
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();
157158
}
158159

159160
/**
@@ -164,10 +165,10 @@ public void opsHyperLogLog() {
164165
ReactiveHyperLogLogOperations<String, String> hyperLogLogOps = reactiveRedisTemplate.opsForHyperLogLog();
165166
String cacheKey = "valueHyperLogLog";
166167

167-
// previous key delete - sync
168+
// previous key delete - sync process
168169
redisTemplate.delete(cacheKey);
169170

170-
// async
171+
// async process
171172
String[] arr = {"1", "2", "2", "3", "4", "5", "5", "5", "5", "6", "7", "7", "7"};
172173
StepVerifier.create(hyperLogLogOps.add(cacheKey, arr)).expectNext(1L).verifyComplete();
173174
StepVerifier.create(hyperLogLogOps.size(cacheKey)).expectNext(7L).verifyComplete();

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /