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 aa5b3e9

Browse files
author
kimyonghwa
committed
reactive redis
1 parent 456b4bd commit aa5b3e9

File tree

1 file changed

+11
-19
lines changed

1 file changed

+11
-19
lines changed

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

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
package com.redis.cluster;
22

3-
import com.redis.cluster.repo.redis.StudentRedisRepo;
43
import org.junit.Test;
54
import org.junit.runner.RunWith;
6-
import org.slf4j.Logger;
7-
import org.slf4j.LoggerFactory;
85
import org.springframework.beans.factory.annotation.Autowired;
96
import org.springframework.boot.test.context.SpringBootTest;
107
import org.springframework.data.geo.Point;
@@ -20,18 +17,12 @@
2017
@SpringBootTest
2118
public class ReactiveRedisClusterTest {
2219

23-
private Logger log = LoggerFactory.getLogger(this.getClass());
24-
25-
2620
@Autowired
2721
private RedisTemplate<String, String> redisTemplate;
2822

2923
@Autowired
3024
private ReactiveRedisTemplate<String, String> reactiveRedisTemplate;
3125

32-
@Autowired
33-
private StudentRedisRepo redisRepo;
34-
3526
/**
3627
* 문자 데이터 구조 처리
3728
*/
@@ -40,7 +31,7 @@ public void opsValue() {
4031
ReactiveValueOperations<String, String> valueOps = reactiveRedisTemplate.opsForValue();
4132
Set<String> cacheKeys = new HashSet<>();
4233
Map<String, String> setDatas = new HashMap<>();
43-
for (int i = 0; i < 10; i++) {
34+
for (int i = 0; i < 100; i++) {
4435
String key = "value_" + i;
4536
cacheKeys.add(key);
4637
setDatas.put(key, String.valueOf(i));
@@ -54,7 +45,7 @@ public void opsValue() {
5445

5546
Mono<List<String>> values = valueOps.multiGet(cacheKeys);
5647
StepVerifier.create(values)
57-
.expectNextMatches(x -> x.size() == 10).verifyComplete();
48+
.expectNextMatches(x -> x.size() == 100).verifyComplete();
5849
}
5950

6051
/**
@@ -116,8 +107,8 @@ public void opsSet() {
116107
StepVerifier.create(setOps.add(cacheKey, String.valueOf(i))).expectNext(1L).verifyComplete();
117108

118109
StepVerifier.create(reactiveRedisTemplate.type(cacheKey)).expectNext(DataType.SET).verifyComplete();
119-
StepVerifier.create(setOps.size(cacheKey)).expectNext(10L);
120-
StepVerifier.create(setOps.isMember(cacheKey, "5")).expectNext(true);
110+
StepVerifier.create(setOps.size(cacheKey)).expectNext(10L).verifyComplete();
111+
StepVerifier.create(setOps.isMember(cacheKey, "5")).expectNext(true).verifyComplete();
121112
}
122113

123114
/**
@@ -144,24 +135,25 @@ public void opsSortedSet() {
144135
* Geo 데이터 구조 처리 - 좌표 정보 처리, 타입은 zset으로 저장.
145136
*/
146137
@Test
147-
public void opsGeo() throws Exception {
148-
GeoOperations<String, String> geoOpsSync = redisTemplate.opsForGeo();
138+
public void opsGeo() {
149139
ReactiveGeoOperations<String, String> geoOps = reactiveRedisTemplate.opsForGeo();
150140
String[] cities = {"서울", "부산"};
151-
String[] gu = {"강남구", "서초구", "관악구", "동작구", "마포구", "사하구", "해운대구", "영도구", "동래구", "수영구"};
141+
String[][] gu = {{"강남구", "서초구", "관악구", "동작구", "마포구"}, {"사하구", "해운대구", "영도구", "동래구", "수영구"}};
152142
String cacheKey = "valueGeo";
153143

154144
// previous key delete - sync
155145
redisTemplate.delete(cacheKey);
156146

147+
Map<String, Point> memberCoordiateMap = new HashMap<>();
157148
for (int x = 0; x < cities.length; x++) {
158-
for (int y = 0; y < gu.length / 2; y++) {
159-
geoOpsSync.add(cacheKey, new Point(x, y), gu[x * y]);
149+
for (int y = 0; y < 5; y++) {
150+
memberCoordiateMap.put(gu[x][y], new Point(x, y));
160151
}
161152
}
162153
// async
154+
StepVerifier.create(geoOps.add(cacheKey, memberCoordiateMap)).expectNext(10L).verifyComplete();
163155
StepVerifier.create(geoOps.distance(cacheKey, "강남구", "동작구")).expectNextMatches(x -> x.getValue() == 333678.8605).verifyComplete();
164-
StepVerifier.create(geoOps.position(cacheKey, "동작구")).expectNextMatches(x -> x.getX() == 0.9999999403953552 && x.getY() == 3.0000009121501066).verifyComplete();
156+
StepVerifier.create(geoOps.position(cacheKey, "동작구")).expectNextMatches(x -> x.getX() == 0.000003 && x.getY() == 3.000001).verifyComplete();
165157
}
166158

167159
/**

0 commit comments

Comments
(0)

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