Module Hub Beta


key cap score member [score member ...]

Adds members to a Sorted Set stored in key, keeping it at cap cardinality. Removes bottom scoring members as needed to meet the limit.

Return Value

Integer reply: the number of members added to the Sorted Set.


redis> ZADD myzset 1 a 2 b 3 c 4 d 5 e
(integer) 5
redis> ZADDCAPPED myzset 5 3 foo
(integer) 1
redis> ZRANGE myzset 0 -1
1) “b”
2) “c”
3) “foo”
4) “d”
5) “e”

© 2017 Redis Labs, Inc. All rights reserved.