ARGETRANGE to read every slot in an inclusive index range.
The reply always has exactly one element per index in the range, with null for the slots that are empty, so the position of a value in the reply tells you its index without sending the indexes back. That makes it the right command when the range is mostly populated; for a sparse range, ARSCAN returns only the occupied slots together with their indexes.
Passing a start greater than the end reverses the order of the reply rather than returning an error, which is how you read a window newest-first. A range wider than 1,000,000 indexes is rejected, because the reply is materialized in full.
See the array command overview for the data model these commands share.
Syntax
Arguments
Important points
- The range is inclusive at both ends and the reply always has
|end - start| + 1elements. - When
<start>is greater than<end>, the reply is ordered from the higher index down to the lower one. - A range covering more than 1,000,000 indexes returns
ERR range exceeds maximum of 1000000 items.
Response
The reply reports the result of the operation. Error replies have the same shape in RESP2 and RESP3 and are surfaced as exceptions by the SDKs below.Client libraries often decode bulk strings, maps, sets, and numeric strings into language-native values. The table describes the Redis wire reply.
Examples
TCP examples use the TLSREDIS_URL from the Upstash console. REST examples use UPSTASH_REDIS_REST_URL and UPSTASH_REDIS_REST_TOKEN.
Redis CLI
Redis CLI
@upstash/redis
@upstash/redis
This command is not supported yet in
@upstash/redis.upstash_redis
upstash_redis
This command is not supported yet in
upstash_redis.ioredis
ioredis
node-redis
node-redis
redis-py
redis-py
go-redis
go-redis
jedis
jedis
redis-rs
redis-rs