Skip to main content

ZRANGESTORE

Syntax

ZRANGESTORE destination source start stop [BYSCORE | BYLEX] [REV] [LIMIT offset count] [WITHSCORES]

Module

sortedset

Categories

write slow sortedset

Description

Retrieve the range of elements in the sorted set and store it in destination.

Options

  • BYSCORE - Sorts the elements in accending order of score before calculating the range.
  • BYLEX - Sorts the elements in ascending lexicographical order before calcularing the range. This option only works if all the members have the same score.
  • REV - Reverse the order determined by BYSCORE or BYLEX.
  • LIMIT - Offset determines where SugarDB will start counting from after the previous modification. Count is the number of elements to extract after the offset.
  • WITHSCORES - Whether the result should include scores.

Examples

Get range by score and store it at the destination key:

db, err := sugardb.NewSugarDB()
if err != nil {
log.Fatal(err)
}
cardinality, err := db.ZRangeStore(
"destination", "source", "11.55", "15.66",
db.ZRangeStoreOptions{
ByScore: true,
Rev: true,
WithScores: true,
Offset: 0,
Count: 2,
})