Skip to content

Commit 9bcd495

Browse files
authored
RI-8219: Add Array read endpoints + key-info strategy (#6064)
1 parent bc32a4b commit 9bcd495

57 files changed

Lines changed: 2441 additions & 68 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

redisinsight/api/bruno/RedisInsight/Array/Create Array (Contiguous).bru

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ docs {
3535
|-------|------|-------------|
3636
| `keyName` | string | The key name for the new Array |
3737
| `mode` | string | Must be `contiguous` for this request shape |
38-
| `startIndex` | string | Start index as a numeric string (`0` to `18446744073709551615`) |
38+
| `startIndex` | string | Start index as a numeric string (`0` to `18446744073709551614`) |
3939
| `values` | string[] | Value(s) to write starting at `startIndex` |
4040
| `expire` | number (optional) | TTL in seconds |
4141

@@ -47,7 +47,7 @@ docs {
4747

4848
| Status | Condition |
4949
|--------|-----------|
50-
| `400` | Validation failed, e.g. a non-canonical index: `startIndex must be an integer string between 0 and 18446744073709551615` |
50+
| `400` | Validation failed, e.g. a non-canonical index: `startIndex must be an integer string between 0 and 18446744073709551614` |
5151
| `403` | User has no permissions |
5252
| `409` | Key with this name already exists |
5353
}

redisinsight/api/bruno/RedisInsight/Array/Create Array (Sparse).bru

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ docs {
3838
| `keyName` | string | The key name for the new Array |
3939
| `mode` | string | Must be `sparse` for this request shape |
4040
| `elements` | array | Index/value pairs to write |
41-
| `elements[].index` | string | Element index as a numeric string (`0` to `18446744073709551615`) |
41+
| `elements[].index` | string | Element index as a numeric string (`0` to `18446744073709551614`) |
4242
| `elements[].value` | string | Element value |
4343
| `expire` | number (optional) | TTL in seconds |
4444

@@ -50,7 +50,7 @@ docs {
5050

5151
| Status | Condition |
5252
|--------|-----------|
53-
| `400` | Validation failed, e.g. a non-canonical index: `elements.0.index must be an integer string between 0 and 18446744073709551615` |
53+
| `400` | Validation failed, e.g. a non-canonical index: `elements.0.index must be an integer string between 0 and 18446744073709551614` |
5454
| `403` | User has no permissions |
5555
| `409` | Key with this name already exists |
5656
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
meta {
2+
name: Get Count
3+
type: http
4+
seq: 4
5+
}
6+
7+
post {
8+
url: {{API_URL}}/databases/{{DB_INSTANCE_ID}}/array/get-count
9+
body: json
10+
auth: inherit
11+
}
12+
13+
body:json {
14+
{
15+
"keyName": "readings"
16+
}
17+
}
18+
19+
docs {
20+
# ARCOUNT
21+
22+
Returns the number of populated (non-empty) elements in the array.
23+
Unsigned 64-bit integer returned as a numeric string.
24+
25+
## Response
26+
27+
```
28+
{
29+
"keyName": "readings",
30+
"count": "5"
31+
}
32+
```
33+
34+
## Errors
35+
36+
| Status | When |
37+
|--------|------|
38+
| `400` | Key holds a non-array type. |
39+
| `403` | User has no permission for `ARCOUNT`. |
40+
| `404` | Key does not exist. |
41+
}
42+
43+
settings {
44+
encodeUrl: true
45+
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
meta {
2+
name: Get Element (empty slot)
3+
type: http
4+
seq: 8
5+
}
6+
7+
post {
8+
url: {{API_URL}}/databases/{{DB_INSTANCE_ID}}/array/get-element
9+
body: json
10+
auth: inherit
11+
}
12+
13+
body:json {
14+
{
15+
"keyName": "readings",
16+
"index": "3"
17+
}
18+
}
19+
20+
docs {
21+
# ARGET — empty slot
22+
23+
Same endpoint as **Get Element**, pre-filled to query an **unset index**
24+
on the seeded `readings` key. With the `Seed Sample Data` fixture
25+
populating indexes `0`, `1`, `5`, asking for index `3` exercises the
26+
gap-preserving semantics of Redis arrays.
27+
28+
## Why this preset exists
29+
30+
A common reviewer assumption is "missing index → 404". For arrays it
31+
isn't: the key exists and the array's logical length still spans the
32+
requested index, so the API returns `200 OK` with a `null` `value`.
33+
Only a missing **key** returns 404.
34+
35+
## Response
36+
37+
```
38+
{
39+
"keyName": "readings",
40+
"value": null
41+
}
42+
```
43+
44+
## Compare with
45+
46+
- **Get Element** (`index: "1"`) → `"value": "20.4"` (slot is set).
47+
- **Get Element** (`keyName: "no-such-key"`) → `404 Not Found` (key missing).
48+
}
49+
50+
settings {
51+
encodeUrl: true
52+
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
meta {
2+
name: Get Element
3+
type: http
4+
seq: 6
5+
}
6+
7+
post {
8+
url: {{API_URL}}/databases/{{DB_INSTANCE_ID}}/array/get-element
9+
body: json
10+
auth: inherit
11+
}
12+
13+
body:json {
14+
{
15+
"keyName": "readings",
16+
"index": "1"
17+
}
18+
}
19+
20+
docs {
21+
# ARGET
22+
23+
Get the value at a single index. Returns `null` for an empty slot or an
24+
index past the array length.
25+
26+
## Request body
27+
28+
| Field | Type | Notes |
29+
|-----------|--------|--------------------------------------------------------|
30+
| `keyName` | string | The Array key name. |
31+
| `index` | string | Unsigned 64-bit integer as string. |
32+
33+
## Response
34+
35+
```
36+
{
37+
"keyName": "readings",
38+
"value": "20.4"
39+
}
40+
```
41+
42+
## Errors
43+
44+
| Status | When |
45+
|--------|------|
46+
| `400` | Key holds a non-array type. |
47+
| `403` | User has no permission for `ARGET`. |
48+
| `404` | Key does not exist. |
49+
}
50+
51+
settings {
52+
encodeUrl: true
53+
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
meta {
2+
name: Get Elements
3+
type: http
4+
seq: 7
5+
}
6+
7+
post {
8+
url: {{API_URL}}/databases/{{DB_INSTANCE_ID}}/array/get-elements
9+
body: json
10+
auth: inherit
11+
}
12+
13+
body:json {
14+
{
15+
"keyName": "readings",
16+
"indexes": ["0", "3", "5"]
17+
}
18+
}
19+
20+
docs {
21+
# ARMGET
22+
23+
Get values at multiple indexes in one round-trip. Returns an array of
24+
`value | null`, one entry per requested index, in request order.
25+
26+
## Request body
27+
28+
| Field | Type | Notes |
29+
|-----------|----------|------------------------------------------------------|
30+
| `keyName` | string | The Array key name. |
31+
| `indexes` | string[] | 1 to 1,000,000 indexes; each unsigned 64-bit as string. |
32+
33+
## Response
34+
35+
```
36+
{
37+
"keyName": "readings",
38+
"elements": ["20.1", null, "21.4"]
39+
}
40+
```
41+
42+
## Errors
43+
44+
| Status | When |
45+
|--------|------|
46+
| `400` | `indexes` is empty or exceeds 1,000,000 entries, any index is not a valid unsigned 64-bit integer string, or the key holds a non-array type. |
47+
| `403` | User has no permission for `ARMGET`. |
48+
| `404` | Key does not exist. |
49+
}
50+
51+
settings {
52+
encodeUrl: true
53+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
meta {
2+
name: Get Length
3+
type: http
4+
seq: 3
5+
}
6+
7+
post {
8+
url: {{API_URL}}/databases/{{DB_INSTANCE_ID}}/array/get-length
9+
body: json
10+
auth: inherit
11+
}
12+
13+
body:json {
14+
{
15+
"keyName": "readings"
16+
}
17+
}
18+
19+
docs {
20+
# ARLEN
21+
22+
Returns the logical length of the array — highest set index + 1 (includes
23+
gaps). Unsigned 64-bit integer returned as a numeric string.
24+
25+
## Response
26+
27+
```
28+
{
29+
"keyName": "readings",
30+
"length": "7"
31+
}
32+
```
33+
34+
## Errors
35+
36+
| Status | When |
37+
|--------|------|
38+
| `400` | Key holds a non-array type. |
39+
| `403` | User has no permission for `ARLEN`. |
40+
| `404` | Key does not exist. |
41+
}
42+
43+
settings {
44+
encodeUrl: true
45+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
meta {
2+
name: Get Next Index
3+
type: http
4+
seq: 5
5+
}
6+
7+
post {
8+
url: {{API_URL}}/databases/{{DB_INSTANCE_ID}}/array/get-next-index
9+
body: json
10+
auth: inherit
11+
}
12+
13+
body:json {
14+
{
15+
"keyName": "readings"
16+
}
17+
}
18+
19+
docs {
20+
# ARNEXT
21+
22+
Returns the next index that `ARINSERT` would use. Read-only.
23+
Unsigned 64-bit integer returned as a numeric string.
24+
25+
## Response
26+
27+
```
28+
{
29+
"keyName": "readings",
30+
"index": "7"
31+
}
32+
```
33+
34+
## Errors
35+
36+
| Status | When |
37+
|--------|------|
38+
| `400` | Key holds a non-array type. |
39+
| `403` | User has no permission for `ARNEXT`. |
40+
| `404` | Key does not exist. |
41+
}
42+
43+
settings {
44+
encodeUrl: true
45+
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
meta {
2+
name: Get Range
3+
type: http
4+
seq: 1
5+
}
6+
7+
post {
8+
url: {{API_URL}}/databases/{{DB_INSTANCE_ID}}/array/get-range
9+
body: json
10+
auth: inherit
11+
}
12+
13+
body:json {
14+
{
15+
"keyName": "readings",
16+
"start": "0",
17+
"end": "6"
18+
}
19+
}
20+
21+
docs {
22+
# ARGETRANGE
23+
24+
Read an inclusive range of elements from an Array key. Empty slots are
25+
returned as `null`. `start` must be less than or equal to `end`.
26+
27+
## Request body
28+
29+
| Field | Type | Notes |
30+
|-----------|--------|-----------------------------------------------------------|
31+
| `keyName` | string | The Array key name. |
32+
| `start` | string | Inclusive start index. Unsigned 64-bit integer as string. |
33+
| `end` | string | Inclusive end index. Unsigned 64-bit integer as string. Must be ≥ `start`. |
34+
35+
## Response
36+
37+
```
38+
{
39+
"keyName": "readings",
40+
"elements": ["20.1", "20.4", "20.9", null, null, "21.4", "21.9"]
41+
}
42+
```
43+
44+
## Errors
45+
46+
| Status | When |
47+
|--------|------|
48+
| `400` | `start` is greater than `end`, range exceeds 1,000,000 elements per call, or the key holds a non-array type. |
49+
| `403` | User has no permission for `ARGETRANGE`. |
50+
| `404` | Key does not exist. |
51+
}
52+
53+
settings {
54+
encodeUrl: true
55+
}

0 commit comments

Comments
 (0)