ARMGET
Since 1.1.0Arrays
Syntax
ARMGET key index [index ...]Returns the values at several indexes in the array at key, in one call. The reply has one entry per index, in the order the indexes were given, with nil for an empty slot; the same index can be asked for more than once. A missing key gives an entry of nil for every index, the same shape as an array whose slots are all empty.
Indexes are whole numbers from 0. They are all checked before anything is read, so one bad index fails the whole command. For a contiguous run of slots, ARGETRANGE is shorter to write. To write several slots at once, use ARMSET.
Reply
- An array with one entry per index: the value as a bulk string, or
nilfor an empty slot.
Errors
ERR invalid array indexfor an index that is negative or not a whole number.WRONGTYPEif the key holds a value that is not an array.
Examples
> ARSET a 0 x y z
(integer) 3
> ARSET a 5 w
(integer) 1
> ARMGET a 0 3 5
1) "x"
2) (nil)
3) "w"
> ARMGET a 5 0 5
1) "w"
2) "x"
3) "w"
> ARMGET nokey 0 1
1) (nil)
2) (nil)