@@ -3639,15 +3639,15 @@ void stream_xadd_with_xaddparams() {
36393639 StreamEntryID result = jedis .xadd (nonExistentKey , params , hash );
36403640 assertNull (result , "XADD with NOMKSTREAM should return null for non-existent stream" );
36413641
3642- // Test with MAXLEN trimming
3642+ // Test with MAXLEN trimming (exact)
36433643 String trimKey = "stream:" + UUID .randomUUID ();
36443644 for (int i = 0 ; i < 5 ; i ++) {
36453645 jedis .xadd (trimKey , Map .of ("i" , String .valueOf (i )));
36463646 }
3647- params = redis .clients .jedis .params .XAddParams .xAddParams ().maxLen (3 );
3647+ params = redis .clients .jedis .params .XAddParams .xAddParams ().maxLenExact (3 );
36483648 jedis .xadd (trimKey , params , Map .of ("new" , "entry" ));
36493649 long len = jedis .xlen (trimKey );
3650- assertTrue (len <= 4 , "Stream should be trimmed to approximately 3 entries" );
3650+ assertTrue (len <= 3 , "Stream should be trimmed to exactly 3 entries" );
36513651 }
36523652
36533653 @ Test
@@ -3657,24 +3657,36 @@ void stream_xtrim_with_xtrimparams() {
36573657 jedis .xadd (key , Map .of ("i" , String .valueOf (i )));
36583658 }
36593659
3660- // Test MAXLEN with XTrimParams
3660+ // Test MAXLEN with XTrimParams (exact trimming)
36613661 redis .clients .jedis .params .XTrimParams params =
3662- redis .clients .jedis .params .XTrimParams .xTrimParams ().maxLen (5 );
3662+ redis .clients .jedis .params .XTrimParams .xTrimParams ().maxLenExact (5 );
36633663 long trimmed = jedis .xtrim (key , params );
36643664 assertTrue (trimmed >= 0 , "XTRIM with XTrimParams should return non-negative count" );
36653665 long len = jedis .xlen (key );
3666- assertTrue (len <= 5 , "Stream should be trimmed to approximately 5 entries" );
3666+ assertTrue (len <= 5 , "Stream should be trimmed to exactly 5 entries" );
36673667
3668- // Test MINID with XTrimParams
3668+ // Test MAXLEN with approximate trimming
3669+ String key3 = "stream:" + UUID .randomUUID ();
3670+ for (int i = 0 ; i < 10 ; i ++) {
3671+ jedis .xadd (key3 , Map .of ("i" , String .valueOf (i )));
3672+ }
3673+ params = redis .clients .jedis .params .XTrimParams .xTrimParams ().maxLen (5 );
3674+ jedis .xtrim (key3 , params );
3675+ len = jedis .xlen (key3 );
3676+ assertTrue (
3677+ len <= 10 && len >= 5 ,
3678+ "Stream with approximate trim should be reduced but may not be exact" );
3679+
3680+ // Test MINID with XTrimParams (exact trimming)
36693681 String key2 = "stream:" + UUID .randomUUID ();
36703682 StreamEntryID firstId = jedis .xadd (key2 , Map .of ("a" , "1" ));
36713683 jedis .xadd (key2 , Map .of ("b" , "2" ));
36723684 StreamEntryID thirdId = jedis .xadd (key2 , Map .of ("c" , "3" ));
36733685
3674- params = redis .clients .jedis .params .XTrimParams .xTrimParams ().minId (thirdId );
3686+ params = redis .clients .jedis .params .XTrimParams .xTrimParams ().minIdExact (thirdId );
36753687 jedis .xtrim (key2 , params );
36763688 len = jedis .xlen (key2 );
3677- assertTrue (len <= 1 , "Stream should be trimmed to entries >= minId" );
3689+ assertTrue (len == 1 , "Stream should be trimmed to exactly entries >= minId" );
36783690 }
36793691
36803692 // --- ACL command integration tests ---
0 commit comments