Skip to content

Feature Request: ZRANDMEMBER #6323

@boramalper

Description

@boramalper

Since redis does not support expiring set members, one common pattern is to use ordered sets instead and ZREMRANGEBYSCORE -inf $now to delete expired keys periodically (see #135).

My use case requires choosing N distinct elements from an ordered set at random, which is not supported by ordered sets currently, i.e. ZRANDMEMBER doesn't exist.

I think ZRANDMEMBER shall have the following signature:

ZRANDMEMBER key [count] [min max]

where min and max are both inclusive and allow minus/plus infinity (which are also their default values, respectively).

ZRANDMEMBER shall return abs(count) elements (whose semantics are the same as SRANDMEMBER) from the ordered set key where each returned element has a score s between min and max (inclusive).

I'd be happy to implement it too if anyone is willing to supervise.

Metadata

Metadata

Assignees

No one assigned

    Labels

    state:help-wantedNo member is currently implementing this change

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions