23
23
import static org .springframework .data .redis .connection .ClusterTestVariables .*;
24
24
import static org .springframework .data .redis .connection .RedisGeoCommands .DistanceUnit .*;
25
25
import static org .springframework .data .redis .connection .RedisGeoCommands .GeoRadiusCommandArgs .*;
26
+ import static org .springframework .data .redis .connection .RedisZSetCommands .*;
26
27
import static org .springframework .data .redis .core .ScanOptions .*;
27
28
28
29
import io .lettuce .core .cluster .RedisClusterClient ;
53
54
import org .springframework .data .redis .connection .RedisListCommands .Position ;
54
55
import org .springframework .data .redis .connection .RedisStringCommands .BitOperation ;
55
56
import org .springframework .data .redis .connection .RedisStringCommands .SetOption ;
56
- import org .springframework .data .redis .connection .RedisZSetCommands .Range ;
57
- import org .springframework .data .redis .connection .RedisZSetCommands .Tuple ;
58
57
import org .springframework .data .redis .connection .ValueEncoding .RedisValueEncoding ;
59
- import org .springframework .data .redis .connection .jedis .JedisConverters ;
60
58
import org .springframework .data .redis .core .Cursor ;
61
59
import org .springframework .data .redis .core .ScanOptions ;
62
60
import org .springframework .data .redis .core .types .Expiration ;
@@ -996,7 +994,7 @@ public void keysShouldReturnAllKeysForSpecificNode() {
996
994
nativeConnection .set (KEY_2 , VALUE_2 );
997
995
998
996
Set <byte []> keysOnNode = clusterConnection .keys (new RedisClusterNode ("127.0.0.1" , 7379 , SlotRange .empty ()),
999
- JedisConverters .toBytes ("*" ));
997
+ LettuceConverters .toBytes ("*" ));
1000
998
1001
999
assertThat (keysOnNode ).contains (KEY_2_BYTES );
1002
1000
assertThat (keysOnNode ).doesNotContain (KEY_1_BYTES );
@@ -2082,6 +2080,40 @@ public void zRangeByLexShouldReturnResultCorrectly() {
2082
2080
LettuceConverters .toBytes ("c" ), LettuceConverters .toBytes ("d" ));
2083
2081
}
2084
2082
2083
+ @ Test // GH-1998
2084
+ public void zRevRangeByLexShouldReturnValuesCorrectly () {
2085
+
2086
+ nativeConnection .zadd (KEY_1 , 0 , "a" );
2087
+ nativeConnection .zadd (KEY_1 , 0 , "b" );
2088
+ nativeConnection .zadd (KEY_1 , 0 , "c" );
2089
+ nativeConnection .zadd (KEY_1 , 0 , "d" );
2090
+ nativeConnection .zadd (KEY_1 , 0 , "e" );
2091
+ nativeConnection .zadd (KEY_1 , 0 , "f" );
2092
+ nativeConnection .zadd (KEY_1 , 0 , "g" );
2093
+
2094
+ Set <byte []> values = clusterConnection .zRevRangeByLex (KEY_1_BYTES , Range .range ().lte ("c" ));
2095
+
2096
+ assertThat (values ).containsExactly (LettuceConverters .toBytes ("c" ), LettuceConverters .toBytes ("b" ),
2097
+ LettuceConverters .toBytes ("a" ));
2098
+ assertThat (values ).doesNotContain (LettuceConverters .toBytes ("d" ), LettuceConverters .toBytes ("e" ),
2099
+ LettuceConverters .toBytes ("f" ), LettuceConverters .toBytes ("g" ));
2100
+
2101
+ values = clusterConnection .zRevRangeByLex (KEY_1_BYTES , Range .range ().lt ("c" ));
2102
+ assertThat (values ).containsExactly (LettuceConverters .toBytes ("b" ), LettuceConverters .toBytes ("a" ));
2103
+ assertThat (values ).doesNotContain (LettuceConverters .toBytes ("c" ));
2104
+
2105
+ values = clusterConnection .zRevRangeByLex (KEY_1_BYTES , Range .range ().gte ("aaa" ).lt ("g" ));
2106
+ assertThat (values ).containsExactly (LettuceConverters .toBytes ("f" ), LettuceConverters .toBytes ("e" ),
2107
+ LettuceConverters .toBytes ("d" ), LettuceConverters .toBytes ("c" ), LettuceConverters .toBytes ("b" ));
2108
+ assertThat (values ).doesNotContain (LettuceConverters .toBytes ("a" ), LettuceConverters .toBytes ("g" ));
2109
+
2110
+ values = clusterConnection .zRevRangeByLex (KEY_1_BYTES , Range .range ().lte ("d" ), Limit .limit ().count (2 ).offset (1 ));
2111
+
2112
+ assertThat (values ).hasSize (2 ).containsExactly (LettuceConverters .toBytes ("c" ), LettuceConverters .toBytes ("b" ));
2113
+ assertThat (values ).doesNotContain (LettuceConverters .toBytes ("a" ), LettuceConverters .toBytes ("d" ),
2114
+ LettuceConverters .toBytes ("e" ), LettuceConverters .toBytes ("f" ), LettuceConverters .toBytes ("g" ));
2115
+ }
2116
+
2085
2117
@ Test // DATAREDIS-315
2086
2118
public void zRangeByScoreShouldReturnValuesCorrectly () {
2087
2119
@@ -2398,46 +2430,46 @@ void refcountReturnsNullWhenKeyDoesNotExist() {
2398
2430
@ Test // DATAREDIS-562
2399
2431
void bitFieldSetShouldWorkCorrectly () {
2400
2432
2401
- assertThat (clusterConnection .stringCommands ().bitField (JedisConverters .toBytes (KEY_1 ),
2433
+ assertThat (clusterConnection .stringCommands ().bitField (LettuceConverters .toBytes (KEY_1 ),
2402
2434
create ().set (INT_8 ).valueAt (BitFieldSubCommands .Offset .offset (0L )).to (10L ))).containsExactly (0L );
2403
- assertThat (clusterConnection .stringCommands ().bitField (JedisConverters .toBytes (KEY_1 ),
2435
+ assertThat (clusterConnection .stringCommands ().bitField (LettuceConverters .toBytes (KEY_1 ),
2404
2436
create ().set (INT_8 ).valueAt (BitFieldSubCommands .Offset .offset (0L )).to (20L ))).containsExactly (10L );
2405
2437
}
2406
2438
2407
2439
@ Test // DATAREDIS-562
2408
2440
void bitFieldGetShouldWorkCorrectly () {
2409
2441
2410
- assertThat (clusterConnection .stringCommands ().bitField (JedisConverters .toBytes (KEY_1 ),
2442
+ assertThat (clusterConnection .stringCommands ().bitField (LettuceConverters .toBytes (KEY_1 ),
2411
2443
create ().get (INT_8 ).valueAt (BitFieldSubCommands .Offset .offset (0L )))).containsExactly (0L );
2412
2444
}
2413
2445
2414
2446
@ Test // DATAREDIS-562
2415
2447
void bitFieldIncrByShouldWorkCorrectly () {
2416
2448
2417
- assertThat (clusterConnection .stringCommands ().bitField (JedisConverters .toBytes (KEY_1 ),
2449
+ assertThat (clusterConnection .stringCommands ().bitField (LettuceConverters .toBytes (KEY_1 ),
2418
2450
create ().incr (INT_8 ).valueAt (BitFieldSubCommands .Offset .offset (100L )).by (1L ))).containsExactly (1L );
2419
2451
}
2420
2452
2421
2453
@ Test // DATAREDIS-562
2422
2454
void bitFieldIncrByWithOverflowShouldWorkCorrectly () {
2423
2455
2424
- assertThat (clusterConnection .stringCommands ().bitField (JedisConverters .toBytes (KEY_1 ),
2456
+ assertThat (clusterConnection .stringCommands ().bitField (LettuceConverters .toBytes (KEY_1 ),
2425
2457
create ().incr (unsigned (2 )).valueAt (BitFieldSubCommands .Offset .offset (102L )).overflow (FAIL ).by (1L )))
2426
2458
.containsExactly (1L );
2427
- assertThat (clusterConnection .stringCommands ().bitField (JedisConverters .toBytes (KEY_1 ),
2459
+ assertThat (clusterConnection .stringCommands ().bitField (LettuceConverters .toBytes (KEY_1 ),
2428
2460
create ().incr (unsigned (2 )).valueAt (BitFieldSubCommands .Offset .offset (102L )).overflow (FAIL ).by (1L )))
2429
2461
.containsExactly (2L );
2430
- assertThat (clusterConnection .stringCommands ().bitField (JedisConverters .toBytes (KEY_1 ),
2462
+ assertThat (clusterConnection .stringCommands ().bitField (LettuceConverters .toBytes (KEY_1 ),
2431
2463
create ().incr (unsigned (2 )).valueAt (BitFieldSubCommands .Offset .offset (102L )).overflow (FAIL ).by (1L )))
2432
2464
.containsExactly (3L );
2433
- assertThat (clusterConnection .stringCommands ().bitField (JedisConverters .toBytes (KEY_1 ),
2465
+ assertThat (clusterConnection .stringCommands ().bitField (LettuceConverters .toBytes (KEY_1 ),
2434
2466
create ().incr (unsigned (2 )).valueAt (BitFieldSubCommands .Offset .offset (102L )).overflow (FAIL ).by (1L ))).isNotNull ();
2435
2467
}
2436
2468
2437
2469
@ Test // DATAREDIS-562
2438
2470
void bitfieldShouldAllowMultipleSubcommands () {
2439
2471
2440
- assertThat (clusterConnection .stringCommands ().bitField (JedisConverters .toBytes (KEY_1 ),
2472
+ assertThat (clusterConnection .stringCommands ().bitField (LettuceConverters .toBytes (KEY_1 ),
2441
2473
create ().incr (signed (5 )).valueAt (BitFieldSubCommands .Offset .offset (100L )).by (1L ).get (unsigned (4 )).valueAt (0L )))
2442
2474
.containsExactly (1L , 0L );
2443
2475
}
@@ -2446,13 +2478,13 @@ void bitfieldShouldAllowMultipleSubcommands() {
2446
2478
void bitfieldShouldWorkUsingNonZeroBasedOffset () {
2447
2479
2448
2480
assertThat (
2449
- clusterConnection .stringCommands ().bitField (JedisConverters .toBytes (KEY_1 ),
2481
+ clusterConnection .stringCommands ().bitField (LettuceConverters .toBytes (KEY_1 ),
2450
2482
create ().set (INT_8 ).valueAt (BitFieldSubCommands .Offset .offset (0L ).multipliedByTypeLength ()).to (100L )
2451
2483
.set (INT_8 ).valueAt (BitFieldSubCommands .Offset .offset (1L ).multipliedByTypeLength ()).to (200L )))
2452
2484
.containsExactly (0L , 0L );
2453
2485
assertThat (
2454
2486
clusterConnection .stringCommands ()
2455
- .bitField (JedisConverters .toBytes (KEY_1 ),
2487
+ .bitField (LettuceConverters .toBytes (KEY_1 ),
2456
2488
create ().get (INT_8 ).valueAt (BitFieldSubCommands .Offset .offset (0L ).multipliedByTypeLength ()).get (INT_8 )
2457
2489
.valueAt (BitFieldSubCommands .Offset .offset (1L ).multipliedByTypeLength ()))).containsExactly (100L ,
2458
2490
-56L );
0 commit comments