|
24 | 24 | import org.springframework.dao.InvalidDataAccessApiUsageException; |
25 | 25 | import org.springframework.data.redis.connection.ClusterSlotHashUtil; |
26 | 26 | import org.springframework.data.redis.connection.RedisZSetCommands; |
| 27 | +import org.springframework.data.redis.connection.convert.SetConverter; |
27 | 28 | import org.springframework.data.redis.core.Cursor; |
28 | 29 | import org.springframework.data.redis.core.ScanCursor; |
29 | 30 | import org.springframework.data.redis.core.ScanIteration; |
|
40 | 41 | */ |
41 | 42 | class JedisClusterZSetCommands implements RedisZSetCommands { |
42 | 43 |
|
| 44 | + private static final SetConverter<redis.clients.jedis.Tuple, Tuple> TUPLE_SET_CONVERTER = new SetConverter<>( |
| 45 | + JedisConverters::toTuple); |
43 | 46 | private final JedisClusterConnection connection; |
44 | 47 |
|
45 | 48 | JedisClusterZSetCommands(JedisClusterConnection connection) { |
@@ -181,9 +184,9 @@ public Set<Tuple> zRangeByScoreWithScores(byte[] key, Range range, Limit limit) |
181 | 184 |
|
182 | 185 | try { |
183 | 186 | if (limit.isUnlimited()) { |
184 | | - return JedisConverters.toTupleSet(connection.getCluster().zrangeByScoreWithScores(key, min, max)); |
| 187 | + return toTupleSet(connection.getCluster().zrangeByScoreWithScores(key, min, max)); |
185 | 188 | } |
186 | | - return JedisConverters.toTupleSet( |
| 189 | + return toTupleSet( |
187 | 190 | connection.getCluster().zrangeByScoreWithScores(key, min, max, limit.getOffset(), limit.getCount())); |
188 | 191 | } catch (Exception ex) { |
189 | 192 | throw convertJedisAccessException(ex); |
@@ -228,9 +231,9 @@ public Set<Tuple> zRevRangeByScoreWithScores(byte[] key, Range range, Limit limi |
228 | 231 |
|
229 | 232 | try { |
230 | 233 | if (limit.isUnlimited()) { |
231 | | - return JedisConverters.toTupleSet(connection.getCluster().zrevrangeByScoreWithScores(key, max, min)); |
| 234 | + return toTupleSet(connection.getCluster().zrevrangeByScoreWithScores(key, max, min)); |
232 | 235 | } |
233 | | - return JedisConverters.toTupleSet( |
| 236 | + return toTupleSet( |
234 | 237 | connection.getCluster().zrevrangeByScoreWithScores(key, max, min, limit.getOffset(), limit.getCount())); |
235 | 238 | } catch (Exception ex) { |
236 | 239 | throw convertJedisAccessException(ex); |
@@ -379,7 +382,7 @@ public Set<Tuple> zRangeWithScores(byte[] key, long start, long end) { |
379 | 382 | Assert.notNull(key, "Key must not be null!"); |
380 | 383 |
|
381 | 384 | try { |
382 | | - return JedisConverters.toTupleSet(connection.getCluster().zrangeWithScores(key, start, end)); |
| 385 | + return toTupleSet(connection.getCluster().zrangeWithScores(key, start, end)); |
383 | 386 | } catch (Exception ex) { |
384 | 387 | throw convertJedisAccessException(ex); |
385 | 388 | } |
@@ -411,7 +414,7 @@ public Set<Tuple> zRangeByScoreWithScores(byte[] key, double min, double max) { |
411 | 414 | Assert.notNull(key, "Key must not be null!"); |
412 | 415 |
|
413 | 416 | try { |
414 | | - return JedisConverters.toTupleSet(connection.getCluster().zrangeByScoreWithScores(key, min, max)); |
| 417 | + return toTupleSet(connection.getCluster().zrangeByScoreWithScores(key, min, max)); |
415 | 418 | } catch (Exception ex) { |
416 | 419 | throw convertJedisAccessException(ex); |
417 | 420 | } |
@@ -452,7 +455,7 @@ public Set<Tuple> zRangeByScoreWithScores(byte[] key, double min, double max, lo |
452 | 455 | } |
453 | 456 |
|
454 | 457 | try { |
455 | | - return JedisConverters.toTupleSet(connection.getCluster().zrangeByScoreWithScores(key, min, max, |
| 458 | + return toTupleSet(connection.getCluster().zrangeByScoreWithScores(key, min, max, |
456 | 459 | Long.valueOf(offset).intValue(), Long.valueOf(count).intValue())); |
457 | 460 | } catch (Exception ex) { |
458 | 461 | throw convertJedisAccessException(ex); |
@@ -485,7 +488,7 @@ public Set<Tuple> zRevRangeWithScores(byte[] key, long start, long end) { |
485 | 488 | Assert.notNull(key, "Key must not be null!"); |
486 | 489 |
|
487 | 490 | try { |
488 | | - return JedisConverters.toTupleSet(connection.getCluster().zrevrangeWithScores(key, start, end)); |
| 491 | + return toTupleSet(connection.getCluster().zrevrangeWithScores(key, start, end)); |
489 | 492 | } catch (Exception ex) { |
490 | 493 | throw convertJedisAccessException(ex); |
491 | 494 | } |
@@ -517,7 +520,7 @@ public Set<Tuple> zRevRangeByScoreWithScores(byte[] key, double min, double max) |
517 | 520 | Assert.notNull(key, "Key must not be null!"); |
518 | 521 |
|
519 | 522 | try { |
520 | | - return JedisConverters.toTupleSet(connection.getCluster().zrevrangeByScoreWithScores(key, max, min)); |
| 523 | + return toTupleSet(connection.getCluster().zrevrangeByScoreWithScores(key, max, min)); |
521 | 524 | } catch (Exception ex) { |
522 | 525 | throw convertJedisAccessException(ex); |
523 | 526 | } |
@@ -558,7 +561,7 @@ public Set<Tuple> zRevRangeByScoreWithScores(byte[] key, double min, double max, |
558 | 561 | } |
559 | 562 |
|
560 | 563 | try { |
561 | | - return JedisConverters.toTupleSet(connection.getCluster().zrevrangeByScoreWithScores(key, max, min, |
| 564 | + return toTupleSet(connection.getCluster().zrevrangeByScoreWithScores(key, max, min, |
562 | 565 | Long.valueOf(offset).intValue(), Long.valueOf(count).intValue())); |
563 | 566 | } catch (Exception ex) { |
564 | 567 | throw convertJedisAccessException(ex); |
@@ -819,4 +822,8 @@ private DataAccessException convertJedisAccessException(Exception ex) { |
819 | 822 | return connection.convertJedisAccessException(ex); |
820 | 823 | } |
821 | 824 |
|
| 825 | + private static Set<Tuple> toTupleSet(Set<redis.clients.jedis.Tuple> source) { |
| 826 | + return TUPLE_SET_CONVERTER.convert(source); |
| 827 | + } |
| 828 | + |
822 | 829 | } |
0 commit comments