method
RedisClient.zrangebyscore
Return members in a sorted set with scores within a given range
Returns all the elements in the sorted set at key with a score between min and max (inclusive by default). The elements are considered to be ordered from low to high scores.
Score ranges support:
-infand+inffor negative and positive infinity(prefix for exclusive bounds (e.g.,(5means greater than 5, not including 5)
The sorted set key
Minimum score (can be "-inf", a number, or prefixed with "(" for exclusive)
Maximum score (can be "+inf", a number, or prefixed with "(" for exclusive)
Promise that resolves with array of members
await redis.send("ZADD", ["myzset", "1", "one", "2", "two", "3", "three"]);
const members = await redis.zrangebyscore("myzset", 1, 2);
// Returns: ["one", "two"]Return members in a sorted set with scores within a given range, with scores
The sorted set key
Minimum score
Maximum score
The "WITHSCORES" keyword to return scores along with members
Promise that resolves with array of [member, score, member, score, ...]
await redis.send("ZADD", ["myzset", "1", "one", "2", "two", "3", "three"]);
const result = await redis.zrangebyscore("myzset", 1, 2, "WITHSCORES");
// Returns: ["one", "1", "two", "2"]Return members in a sorted set with scores within a given range, with pagination
The sorted set key
Minimum score
Maximum score
The "LIMIT" keyword
The number of elements to skip
The maximum number of elements to return
Promise that resolves with array of members
await redis.send("ZADD", ["myzset", "1", "one", "2", "two", "3", "three", "4", "four"]);
const result = await redis.zrangebyscore("myzset", "-inf", "+inf", "LIMIT", 1, 2);
// Returns: ["two", "three"]Return members in a sorted set with scores within a given range, with the score values
The sorted set key
Minimum score
Maximum score
Additional options (WITHSCORES, LIMIT offset count)
Promise that resolves with array of members (and scores if WITHSCORES is used)
Return members in a sorted set with scores within a given range, with the score values
The sorted set key
Minimum score
Maximum score
Additional options (WITHSCORES, LIMIT offset count)
Promise that resolves with array of members (and scores if WITHSCORES is used)
Return members in a sorted set with scores within a given range, with various options
The sorted set key
Minimum score
Maximum score
Additional options (WITHSCORES, LIMIT offset count)
Promise that resolves with array of members (and scores if WITHSCORES is used)