Skip to content

Commit

Permalink
Fix the Java example code for Lists using RPUSH (#4074)
Browse files Browse the repository at this point in the history
* fixing the Java code to match the redis cli example and the context

* fixing the tests

---------

Co-authored-by: Mohamed Sanaulla <[email protected]>
  • Loading branch information
sanaulla123 and msanaulla authored Jan 31, 2025
1 parent 07f3868 commit 0d4b0db
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/test/java/io/redis/examples/ListExample.java
Original file line number Diff line number Diff line change
Expand Up @@ -163,20 +163,20 @@ public void run() {
// REMOVE_END

// STEP_START ltrim
long res27 = jedis.lpush("bikes:repairs", "bike:1", "bike:2", "bike:3", "bike:4", "bike:5");
long res27 = jedis.rpush("bikes:repairs", "bike:1", "bike:2", "bike:3", "bike:4", "bike:5");
System.out.println(res27); // >>> 5

String res28 = jedis.ltrim("bikes:repairs", 0, 2);
System.out.println(res28); // >>> OK

List<String> res29 = jedis.lrange("bikes:repairs", 0, -1);
System.out.println(res29); // >>> [bike:5, bike:4, bike:3]
System.out.println(res29); // >>> [bike:1, bike:2, bike:3]
// STEP_END

// REMOVE_START
assertEquals(5, res27);
assertEquals("OK", res28);
assertEquals("[bike:5, bike:4, bike:3]", res29.toString());
assertEquals("[bike:1, bike:2, bike:3]", res29.toString());
jedis.del("bikes:repairs");
// REMOVE_END

Expand Down

0 comments on commit 0d4b0db

Please sign in to comment.