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 EchoVault 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:

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