range

UK[reɪndʒ] US[rendʒ]

n.Range; range; category; (mountains, houses, etc.) arrangement

vi.Search; change; extend; roam

vt. Arrange; (according to a certain position or order) sort; classify...; wander

adj. pasture, grazing area

Third person singular: ranges Plural: ranges Present participle: ranging Past tense: ranged Past participle: ranged

##by

英[baɪ] 美[ baɪ]

prep. Beside...; Expression method; Because; Passed

adv. Passed; Used when expressing retention or preservation; Short visit

score

UK[skɔ:(r)] US[skɔr, skor]

n. score; score; score; 20 pieces

v. score; score ;Score; win

Third person singular: scores Plural: scores Present participle: scoring Past tense: scored Past participle: scored

redis ZRANGEBYSCORE command syntax

Function:Returns all members in the ordered set key whose score value is between min and max (including equal to min or max). The members of the ordered set are arranged in increasing order of score value (from small to large).

Syntax:ZRANGEBYSCORE key min max [WITHSCORES] [LIMIT offset count]

Description:Members with the same score value are in lexicographic order ( lexicographical order) to arrange (this attribute is provided by ordered sets and does not require additional calculations). The optional LIMIT parameter specifies the number and range of returned results (just like SELECT LIMIT offset, count in SQL). Note that when offset is large, the operation of locating offset may require traversing the entire ordered set. This process has the worst complexity is O(N) time. The optional WITHSCORES parameter determines whether the result set returns the members of the sorted set alone, or whether the members of the sorted set are returned along with their score values.

This option is available since Redis 2.0 version.

Available versions:>= 1.0.5

Time complexity:O(log(N) M), N is ordered The cardinality of the set, M is the cardinality of the result set.

Returns:A list of ordered set members with score value (optional) in the specified interval.

redis ZRANGEBYSCORE command example

redis> ZADD salary 2500 jack # 测试数据 (integer) 0 redis> ZADD salary 5000 tom (integer) 0 redis> ZADD salary 12000 peter (integer) 0 redis> ZRANGEBYSCORE salary -inf +inf # 显示整个有序集 1) "jack" 2) "tom" 3) "peter" redis> ZRANGEBYSCORE salary -inf +inf WITHSCORES # 显示整个有序集及成员的 score 值 1) "jack" 2) "2500" 3) "tom" 4) "5000" 5) "peter" 6) "12000" redis> ZRANGEBYSCORE salary -inf 5000 WITHSCORES # 显示工资 <=5000 的所有成员 1) "jack" 2) "2500" 3) "tom" 4) "5000" redis> ZRANGEBYSCORE salary (5000 400000 # 显示工资大于 5000 小于等于 400000 的成员 1) "peter"