Sorted Set

ZSCAN

Scan a sorted set

Arguments

keybodystringrequired

The key of the sorted set.

cursorbodynumber

The cursor, use 0 in the beginning and then use the returned cursor for subsequent calls.

optionsbodyObject
matchbodystring

Glob-style pattern to filter by members.

countbodynumber

Number of members to return per call.

Response

[number, TMember[]]required

The new cursor and the members. If the new cursor is 0 the iteration is complete.

Example
await redis.zadd("key",     { score: 1, member: "a" },    { score: 2, member: "ab" },    { score: 3, member: "b" },    { score: 4, member: "c" },    { score: 5, member: "d" },)const [newCursor, members] = await redis.zscan("key", 0, { match: "a*"});console.log(newCursor); // likely `0` since this is a very small setconsole.log(members); // ["a", "ab"]
withCount
await redis.zadd("key",     { score: 1, member: "a" },    { score: 2, member: "ab" },    { score: 3, member: "b" },    { score: 4, member: "c" },    { score: 5, member: "d" },)const [newCursor, members] = await redis.zscan("key", 0, { match: "a*", count: 1});console.log(newCursor); // likely `0` since this is a very small setconsole.log(members); // ["a"]
Loading search…