127.0.0.1:6379> hello 3
1# "server" => "redis"
2# "version" => "6.2.1"
3# "proto" => (integer) 3
4# "id" => (integer) 2437
5# "mode" => "standalone"
6# "role" => "master"
7# "modules" => (empty array)
127.0.0.1:6379> 
127.0.0.1:6379> 
127.0.0.1:6379> xrange stream - + 
1) 1) "1-0"
   2) 1) "x1"
      2) "x2"
2) 1) "2-0"
   2) 1) "y1"
      2) "y2"
3) 1) "3-0"
   2) 1) "z1"
      2) "z2"
127.0.0.1:6379> 
127.0.0.1:6379> xtrim stream maxlen ~ 0 limit 2
(integer) 3
127.0.0.1:6379> 

limit 2 didn't work, all data was still removed ( return (integer) 3 ), or is my understanding of the limit option wrong?

Comment From: huangzhw

I think it's a bug. I wil try to fix it.

Comment From: guybe7

@monkey92t @huangzhw indeed a bug... thanks (discussion will continue in the PR)

Comment From: huangzhw

Fixed in https://github.com/redis/redis/pull/9048