AROP
AROP key start end <SUM | MIN | MAX | AND | OR | XOR | MATCH value | USED>
- Available since:
- Redis Open Source 8.8.0
- Time complexity:
- O(P) where P is visited positions in touched slices (dense scanned slots + sparse entries), with worst-case O(|end-start|+1) and typical case close to O(N), where N is the number of existing elements in range.
- ACL categories:
-
ARRAY,
Performs aggregate operations on array elements in a range.
Required arguments
key
The name of the key that holds the array.
start
The zero-based integer index of the first element in the range to aggregate.
end
The zero-based integer index of the last element in the range to aggregate (inclusive). The command always scans from the lower to the higher index regardless of argument order.
operation
The aggregate function to apply to all non-empty elements in [start, end]. One of:
SUM— Returns the sum of all numeric values as a bulk string.MIN— Returns the minimum numeric value as a bulk string.MAX— Returns the maximum numeric value as a bulk string.AND— Returns the bitwise AND of all values, treating each as an integer (floats are truncated toward zero).OR— Returns the bitwise OR of all values, treating each as an integer (floats are truncated toward zero).XOR— Returns the bitwise XOR of all values, treating each as an integer (floats are truncated toward zero).MATCH value— Returns the count of elements whose value equalsvalueas an integer reply.USED— Returns the count of non-empty elements in the range as an integer reply.
SUM, MIN, and MAX return nil when no numeric elements are present in the range. AND, OR, and XOR return nil when the range is empty.
Examples
Return information
One of the following:
- Bulk string reply: Result of the operation.
- Integer reply: Integer result for MATCH, USED, AND, OR, XOR.
- Nil reply: Null if no elements match the operation.