{
  "schema_version": 2,
  "id": "develop/data-types/arrays",
  "title": "Redis arrays",
  "url": "https://redis.io/docs/latest/develop/data-types/arrays/",
  "summary": "Introduction to Redis arrays",
  "aliases": [
    "/develop/data-types/array/"
  ],
  "tags": [
    "docs",
    "develop",
    "stack",
    "oss",
    "rs",
    "rc",
    "kubernetes",
    "clients"
  ],
  "last_updated": "2026-09-28T15:41:00+02:00",
  "page_type": "content",
  "content_hash": "e4e44b02607c4609a9868babcd030b64348b34b79e5453730099912abfc4dfdc",
  "sections": [
    {
      "id": "array-command-summary",
      "title": "Array command summary",
      "role": "content",
      "text": "**18 commands in this group:**\n\n[View all array commands](https://redis.io/commands/?group=array)\n\n| Command | Summary | Complexity | Since |\n|---------|---------|------------|-------|\n| [ARCOUNT](https://redis.io/commands/arcount/) | Returns the number of non-empty elements in an array. | O(1) | 8.8.0 |\n| [ARDEL](https://redis.io/commands/ardel/) | Deletes elements at the specified indices in an array. | O(N) where N is the number of indices to delete | 8.8.0 |\n| [ARDELRANGE](https://redis.io/commands/ardelrange/) | Deletes elements in one or more ranges. | Proportional to the number of existing elements... | 8.8.0 |\n| [ARGET](https://redis.io/commands/arget/) | Gets the value at an index in an array. | O(1) | 8.8.0 |\n| [ARGETRANGE](https://redis.io/commands/argetrange/) | Gets values in a range of indices. | O(N) where N is the range length | 8.8.0 |\n| [ARGREP](https://redis.io/commands/argrep/) | Searches array elements in a range using textual predicates. | O(P * C) where P is the number of visited posit... | 8.8.0 |\n| [ARINFO](https://redis.io/commands/arinfo/) | Returns metadata about an array. | O(1), or O(N) with FULL option where N is the n... | 8.8.0 |\n| [ARINSERT](https://redis.io/commands/arinsert/) | Inserts one or more values at consecutive indices. | O(N) where N is the number of values | 8.8.0 |\n| [ARLASTITEMS](https://redis.io/commands/arlastitems/) | Returns the most recently inserted elements. | O(N) where N is the count | 8.8.0 |\n| [ARLEN](https://redis.io/commands/arlen/) | Returns the length of an array (max index + 1). | O(1) | 8.8.0 |\n\n#### Array command summary (part 2)\n\n| Command | Summary | Complexity | Since |\n|---------|---------|------------|-------|\n| [ARMGET](https://redis.io/commands/armget/) | Gets values at multiple indices in an array. | O(N) where N is the number of indices | 8.8.0 |\n| [ARMSET](https://redis.io/commands/armset/) | Sets multiple index-value pairs in an array. | O(N) where N is the number of pairs | 8.8.0 |\n| [ARNEXT](https://redis.io/commands/arnext/) | Returns the next index ARINSERT would use. | O(1) | 8.8.0 |\n| [AROP](https://redis.io/commands/arop/) | Performs aggregate operations on array elements in a range. | O(P) where P is visited positions in touched sl... | 8.8.0 |\n| [ARRING](https://redis.io/commands/arring/) | Inserts values into a ring buffer of specified size, wrapping and truncating as needed. | O(M) normally, O(N+M) on ring resize, where N i... | 8.8.0 |\n| [ARSCAN](https://redis.io/commands/arscan/) | Iterates existing elements in a range, returning index-value pairs. | O(P) where P is visited positions in touched sl... | 8.8.0 |\n| [ARSEEK](https://redis.io/commands/arseek/) | Sets the ARINSERT / ARRING cursor to a specific index. | O(1) | 8.8.0 |\n| [ARSET](https://redis.io/commands/arset/) | Sets one or more contiguous values starting at an index in an array. | O(N) where N is the number of values | 8.8.0 |\n\n\n\nRedis arrays are sparse, index-addressable data structures that map integer indexes (in the range 0 to 2⁶⁴−1) to string values. Unlike lists, elements are accessed directly by index rather than by position in a sequence, and you can set any index without allocating the gaps between occupied slots. This makes arrays well-suited for timestamped event logs, ring buffers over streaming measurements, sliding-window analytics, and other workloads that involve sparse or high-index access patterns."
    },
    {
      "id": "basic-usage",
      "title": "Basic usage",
      "role": "content",
      "text": "Use [`ARSET`](https://redis.io/docs/latest/commands/arset) to write one or more contiguous values starting at a given index, and [`ARGET`](https://redis.io/docs/latest/commands/arget) to read the value at an index. Accessing an unset index returns a nil reply.\n\nWrite contiguous values with ARSET and read a single index with ARGET; an unset index returns nil\n\n**Commands:** ARSET, ARGET\n\n**Complexity:**\n- ARSET: O(N)\n- ARGET: O(1)\n\n**Available in:** Redis CLI, Go, Java (Asynchronous - Lettuce), Java (Reactive - Lettuce), JavaScript (Node.js), PHP, Python\n\n##### Redis CLI\n\n[code example]\n\n##### Go\n\n[code example]\n\n##### Java (Asynchronous - Lettuce)\n\n[code example]\n\n##### Java (Reactive - Lettuce)\n\n[code example]\n\n##### JavaScript (Node.js)\n\n[code example]\n\n##### PHP\n\n[code example]\n\n##### Python\n\n[code example]\n\n\n\nTo write values at arbitrary, non-contiguous indexes, use [`ARMSET`](https://redis.io/docs/latest/commands/armset). To read several indexes in one round trip, use [`ARMGET`](https://redis.io/docs/latest/commands/armget):\n\nWrite to arbitrary, non-contiguous indexes with ARMSET and read several indexes in one round trip with ARMGET\n\n**Commands:** ARMSET, ARMGET\n\n**Complexity:**\n- ARMSET: O(N)\n- ARMGET: O(N)\n\n**Available in:** Redis CLI, Go, Java (Asynchronous - Lettuce), Java (Reactive - Lettuce), JavaScript (Node.js), PHP, Python\n\n##### Redis CLI\n\n[code example]\n\n##### Go\n\n[code example]\n\n##### Java (Asynchronous - Lettuce)\n\n[code example]\n\n##### Java (Reactive - Lettuce)\n\n[code example]\n\n##### JavaScript (Node.js)\n\n[code example]\n\n##### PHP\n\n[code example]\n\n##### Python\n\n[code example]"
    },
    {
      "id": "array-length-vs-element-count",
      "title": "Array length vs. element count",
      "role": "content",
      "text": "Redis arrays expose two distinct size measurements:\n\n- [`ARLEN`](https://redis.io/docs/latest/commands/arlen) returns the *logical length*: the highest set index plus one.\n- [`ARCOUNT`](https://redis.io/docs/latest/commands/arcount) returns the number of *non-empty* elements.\n\nFor a sparse array, these values can differ substantially:\n\nCompare the logical length (ARLEN) with the number of non-empty elements (ARCOUNT) for a sparse array\n\n**Commands:** ARSET, ARLEN, ARCOUNT\n\n**Complexity:**\n- ARSET: O(N)\n- ARLEN: O(1)\n- ARCOUNT: O(1)\n\n**Available in:** Redis CLI, Go, Java (Asynchronous - Lettuce), Java (Reactive - Lettuce), JavaScript (Node.js), PHP, Python\n\n##### Redis CLI\n\n[code example]\n\n##### Go\n\n[code example]\n\n##### Java (Asynchronous - Lettuce)\n\n[code example]\n\n##### Java (Reactive - Lettuce)\n\n[code example]\n\n##### JavaScript (Node.js)\n\n[code example]\n\n##### PHP\n\n[code example]\n\n##### Python\n\n[code example]"
    },
    {
      "id": "reading-ranges",
      "title": "Reading ranges",
      "role": "content",
      "text": "[`ARGETRANGE`](https://redis.io/docs/latest/commands/argetrange) returns every position in a range—including empty slots as nil—in index order. Reversing `start` and `end` reverses the direction:\n\nRead every position in a range with ARGETRANGE, including empty slots returned as nil\n\n**Commands:** ARMSET, ARGETRANGE\n\n**Complexity:**\n- ARMSET: O(N)\n- ARGETRANGE: O(N)\n\n**Available in:** Redis CLI, Go, Java (Asynchronous - Lettuce), Java (Reactive - Lettuce), JavaScript (Node.js), PHP, Python\n\n##### Redis CLI\n\n[code example]\n\n##### Go\n\n[code example]\n\n##### Java (Asynchronous - Lettuce)\n\n[code example]\n\n##### Java (Reactive - Lettuce)\n\n[code example]\n\n##### JavaScript (Node.js)\n\n[code example]\n\n##### PHP\n\n[code example]\n\n##### Python\n\n[code example]\n\n\n\nTo iterate only the elements that exist and retrieve their indexes alongside their values, use [`ARSCAN`](https://redis.io/docs/latest/commands/arscan). It skips empty slots and returns an array of index-value pairs, with an optional `LIMIT` to cap the result size:\n\nIterate only the elements that exist with ARSCAN, retrieving each index alongside its value\n\n**Builds upon:** argetrange\n\n**Commands:** ARSCAN\n\n**Complexity:**\n- ARSCAN: O(P)\n\n**Available in:** Redis CLI, Go, Java (Asynchronous - Lettuce), Java (Reactive - Lettuce), JavaScript (Node.js), PHP, Python\n\n##### Redis CLI\n\n[code example]\n\n##### Go\n\n[code example]\n\n##### Java (Asynchronous - Lettuce)\n\n[code example]\n\n##### Java (Reactive - Lettuce)\n\n[code example]\n\n##### JavaScript (Node.js)\n\n[code example]\n\n##### PHP\n\n[code example]\n\n##### Python\n\n[code example]"
    },
    {
      "id": "sequential-insertion",
      "title": "Sequential insertion",
      "role": "content",
      "text": "[`ARINSERT`](https://redis.io/docs/latest/commands/arinsert) appends values using an internal cursor that advances automatically after each call. Use [`ARNEXT`](https://redis.io/docs/latest/commands/arnext) to inspect where the next insert would land, and [`ARSEEK`](https://redis.io/docs/latest/commands/arseek) to reposition the cursor:\n\nAppend values with ARINSERT using an auto-advancing cursor, inspect it with ARNEXT, and reposition it with ARSEEK\n\n**Commands:** ARINSERT, ARNEXT, ARSEEK\n\n**Complexity:**\n- ARINSERT: O(N)\n- ARNEXT: O(1)\n- ARSEEK: O(1)\n\n**Available in:** Redis CLI, Go, Java (Asynchronous - Lettuce), Java (Reactive - Lettuce), JavaScript (Node.js), PHP, Python\n\n##### Redis CLI\n\n[code example]\n\n##### Go\n\n[code example]\n\n##### Java (Asynchronous - Lettuce)\n\n[code example]\n\n##### Java (Reactive - Lettuce)\n\n[code example]\n\n##### JavaScript (Node.js)\n\n[code example]\n\n##### PHP\n\n[code example]\n\n##### Python\n\n[code example]"
    },
    {
      "id": "ring-buffer-mode",
      "title": "Ring buffer mode",
      "role": "content",
      "text": "[`ARRING`](https://redis.io/docs/latest/commands/arring) turns an array into a fixed-size circular buffer. Each call inserts a value at `insert_idx % size`, wrapping back to index `0` once the window is full and overwriting the oldest entry:\n\nUse ARRING to maintain a fixed-size circular buffer that wraps and overwrites the oldest entry once full\n\n**Commands:** ARRING, ARGET\n\n**Complexity:**\n- ARRING: O(M)\n- ARGET: O(1)\n\n**Available in:** Redis CLI, Go, Java (Asynchronous - Lettuce), Java (Reactive - Lettuce), JavaScript (Node.js), PHP, Python\n\n##### Redis CLI\n\n[code example]\n\n##### Go\n\n[code example]\n\n##### Java (Asynchronous - Lettuce)\n\n[code example]\n\n##### Java (Reactive - Lettuce)\n\n[code example]\n\n##### JavaScript (Node.js)\n\n[code example]\n\n##### PHP\n\n[code example]\n\n##### Python\n\n[code example]\n\n\n\n[`ARLASTITEMS`](https://redis.io/docs/latest/commands/arlastitems) retrieves the *N* most recently inserted elements in chronological order. Pass the `REV` flag to reverse the order:\n\nRetrieve the N most recently inserted elements with ARLASTITEMS, optionally reversing the order with REV\n\n**Builds upon:** arring\n\n**Commands:** ARLASTITEMS\n\n**Complexity:**\n- ARLASTITEMS: O(N)\n\n**Available in:** Redis CLI, Go, Java (Asynchronous - Lettuce), Java (Reactive - Lettuce), JavaScript (Node.js), PHP, Python\n\n##### Redis CLI\n\n[code example]\n\n##### Go\n\n[code example]\n\n##### Java (Asynchronous - Lettuce)\n\n[code example]\n\n##### Java (Reactive - Lettuce)\n\n[code example]\n\n##### JavaScript (Node.js)\n\n[code example]\n\n##### PHP\n\n[code example]\n\n##### Python\n\n[code example]"
    },
    {
      "id": "aggregate-operations",
      "title": "Aggregate operations",
      "role": "content",
      "text": "[`AROP`](https://redis.io/docs/latest/commands/arop) performs a single-pass aggregate over a contiguous range of elements:\n\n| Operation | Description |\n|-----------|-------------|\n| `SUM` | Sum of numeric values |\n| `MIN` | Minimum numeric value |\n| `MAX` | Maximum numeric value |\n| `AND` / `OR` / `XOR` | Bitwise operation on integer values |\n| `MATCH value` | Count of elements equal to `value` |\n| `USED` | Count of non-empty elements in the range |\n\nRun a single-pass aggregate over a contiguous range with AROP, such as SUM, MAX, or a MATCH count\n\n**Commands:** ARMSET, AROP\n\n**Complexity:**\n- ARMSET: O(N)\n- AROP: O(P)\n\n**Available in:** Redis CLI, Go, Java (Asynchronous - Lettuce), Java (Reactive - Lettuce), JavaScript (Node.js), PHP, Python\n\n##### Redis CLI\n\n[code example]\n\n##### Go\n\n[code example]\n\n##### Java (Asynchronous - Lettuce)\n\n[code example]\n\n##### Java (Reactive - Lettuce)\n\n[code example]\n\n##### JavaScript (Node.js)\n\n[code example]\n\n##### PHP\n\n[code example]\n\n##### Python\n\n[code example]"
    },
    {
      "id": "searching-elements",
      "title": "Searching elements",
      "role": "content",
      "text": "[`ARGREP`](https://redis.io/docs/latest/commands/argrep) finds elements in a range whose values match one or more textual predicates and returns their indexes. Empty slots are skipped. Four predicate forms are supported: `EXACT` (full equality), `MATCH` (substring), `GLOB` (the same wildcard syntax as [`SCAN`](https://redis.io/docs/latest/commands/scan) `MATCH`), and `RE` (regular expression). Multiple predicates are combined with `OR` by default, or with `AND` when the option is given. Pass `NOCASE` for case-insensitive comparisons, `WITHVALUES` to return matching values alongside their indexes, and `LIMIT` to cap the number of matches.\n\nThis is particularly useful when an array stores line-indexed text such as a log file, where each element holds one line:\n\nFind elements matching textual predicates (EXACT, MATCH, GLOB, RE) with ARGREP, combined with AND or OR\n\n**Commands:** DEL, ARMSET, ARGREP\n\n**Complexity:**\n- DEL: O(N)\n- ARMSET: O(N)\n- ARGREP: O(P * C)\n\n**Available in:** Redis CLI, Go, Java (Asynchronous - Lettuce), Java (Reactive - Lettuce), JavaScript (Node.js), PHP, Python\n\n##### Redis CLI\n\n[code example]\n\n##### Go\n\n[code example]\n\n##### Java (Asynchronous - Lettuce)\n\n[code example]\n\n##### Java (Reactive - Lettuce)\n\n[code example]\n\n##### JavaScript (Node.js)\n\n[code example]\n\n##### PHP\n\n[code example]\n\n##### Python\n\n[code example]\n\n\n\nThe special values `-` and `+` denote the first and last index of the array. Combined with [ring buffer mode](#ring-buffer-mode), this lets a fixed-size array hold the most recent *N* log lines and be searched in place."
    },
    {
      "id": "deleting-elements",
      "title": "Deleting elements",
      "role": "content",
      "text": "[`ARDEL`](https://redis.io/docs/latest/commands/ardel) deletes one or more elements by index and returns the count of elements actually removed. [`ARDELRANGE`](https://redis.io/docs/latest/commands/ardelrange) removes all elements within an index range; reversing `start` and `end` is supported:\n\nDelete elements by index with ARDEL or remove a whole index range with ARDELRANGE\n\n**Builds upon:** arop\n\n**Commands:** ARDEL, ARDELRANGE\n\n**Complexity:**\n- ARDEL: O(N)\n\n**Available in:** Redis CLI, Go, Java (Asynchronous - Lettuce), Java (Reactive - Lettuce), JavaScript (Node.js), PHP, Python\n\n##### Redis CLI\n\n[code example]\n\n##### Go\n\n[code example]\n\n##### Java (Asynchronous - Lettuce)\n\n[code example]\n\n##### Java (Reactive - Lettuce)\n\n[code example]\n\n##### JavaScript (Node.js)\n\n[code example]\n\n##### PHP\n\n[code example]\n\n##### Python\n\n[code example]\n\n\n\nDeleting the last remaining element removes the key entirely."
    },
    {
      "id": "introspection",
      "title": "Introspection",
      "role": "content",
      "text": "[`ARINFO`](https://redis.io/docs/latest/commands/arinfo) returns metadata about an array's internal structure, including its logical length, element count, and next insert index. Pass the `FULL` option to include per-slice statistics such as fill rates and counts of dense versus sparse slices:\n\n[code example]"
    },
    {
      "id": "configuration",
      "title": "Configuration",
      "role": "configuration",
      "text": "The following configuration parameters affect array behavior:\n- `array-slice-size`\n- `array-sparse-kmax`\n- `array-sparse-kmin`\n\nSee the [Redis configuration page](https://redis.io/docs/latest/operate/oss_and_stack/management/config) for details."
    },
    {
      "id": "performance",
      "title": "Performance",
      "role": "performance",
      "text": "Most array commands are O(1), including [`ARSET`](https://redis.io/docs/latest/commands/arset), [`ARGET`](https://redis.io/docs/latest/commands/arget), [`ARDEL`](https://redis.io/docs/latest/commands/ardel), [`ARINSERT`](https://redis.io/docs/latest/commands/arinsert), [`ARNEXT`](https://redis.io/docs/latest/commands/arnext), [`ARSEEK`](https://redis.io/docs/latest/commands/arseek), [`ARCOUNT`](https://redis.io/docs/latest/commands/arcount), and [`ARLEN`](https://redis.io/docs/latest/commands/arlen). Operations that touch N elements—such as [`ARGETRANGE`](https://redis.io/docs/latest/commands/argetrange), [`ARSCAN`](https://redis.io/docs/latest/commands/arscan), [`ARDELRANGE`](https://redis.io/docs/latest/commands/ardelrange), [`AROP`](https://redis.io/docs/latest/commands/arop), and [`ARLASTITEMS`](https://redis.io/docs/latest/commands/arlastitems)—are O(N). The underlying sliced-array encoding handles both dense and sparse access patterns efficiently, so large index gaps consume very little memory."
    },
    {
      "id": "alternatives",
      "title": "Alternatives",
      "role": "content",
      "text": "Arrays complement rather than replace the other Redis collection types:\n\n- Use [Redis lists](https://redis.io/docs/latest/develop/data-types/lists) when you need push/pop operations at either end, or when you need to insert elements between existing ones.\n- Use [Redis hashes](https://redis.io/docs/latest/develop/data-types/hashes) when values are addressed by field name rather than by numeric index.\n- Use [Redis streams](https://redis.io/docs/latest/develop/data-types/streams) when you need an append-only event log with consumer groups and acknowledgements."
    },
    {
      "id": "limits",
      "title": "Limits",
      "role": "limits",
      "text": "[`ARGETRANGE`](https://redis.io/docs/latest/commands/argetrange) enforces a hard limit of 1,000,000 elements per call to guard against accidentally large range reads."
    }
  ],
  "examples": [
    {
      "id": "basic-usage-ex0",
      "language": "plaintext",
      "code": "> ARSET events:1 0 \"login\" \"click\" \"purchase\"\n(integer) 3\n> ARGET events:1 0\n\"login\"\n> ARGET events:1 999\n(nil)",
      "section_id": "basic-usage"
    },
    {
      "id": "basic-usage-ex1",
      "language": "go",
      "code": "setRes, err := rdb.ARSet(ctx, \"events:1\", 0, \"login\", \"click\", \"purchase\").Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(setRes) // >>> 3\n\n\tgetRes, err := rdb.ARGet(ctx, \"events:1\", 0).Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(getRes) // >>> login\n\n\tmissing, err := rdb.ARGet(ctx, \"events:1\", 999).Result()\n\n\tif err == redis.Nil {\n\t\tfmt.Println(\"<nil>\") // >>> <nil>\n\t} else if err != nil {\n\t\tpanic(err)\n\t} else {\n\t\tfmt.Println(missing)\n\t}",
      "section_id": "basic-usage"
    },
    {
      "id": "basic-usage-ex2",
      "language": "java",
      "code": "CompletableFuture<Void> arsetArgetExample = asyncCommands\n                    .arset(\"events:1\", 0, \"login\", \"click\", \"purchase\")\n                    .thenCompose(res1 -> {\n                        System.out.println(res1);\n                        // >>> 3\n                        return asyncCommands.arget(\"events:1\", 0);\n                    })\n                    .thenCompose(res2 -> {\n                        System.out.println(res2);\n                        // >>> login\n                        return asyncCommands.arget(\"events:1\", 999);\n                    })\n                    .thenAccept(res3 -> {\n                        System.out.println(res3);\n                        // >>> null\n                    })\n                    .toCompletableFuture();\n\n            arsetArgetExample.join();",
      "section_id": "basic-usage"
    },
    {
      "id": "basic-usage-ex3",
      "language": "java",
      "code": "Mono<Long> arsetArget1 = reactiveCommands.arset(\"events:1\", 0, \"login\", \"click\", \"purchase\")\n                    .doOnNext(result -> {\n                        System.out.println(result); // >>> 3\n                    });\n\n            arsetArget1.block();\n\n            Mono<String> arsetArget2 = reactiveCommands.arget(\"events:1\", 0).doOnNext(result -> {\n                System.out.println(result); // >>> login\n            });\n\n            arsetArget2.block();\n\n            Mono<Optional<String>> arsetArget3 = reactiveCommands.arget(\"events:1\", 999)\n                    .map(Optional::of)\n                    .defaultIfEmpty(Optional.empty())\n                    .doOnNext(result -> {\n                        System.out.println(result.orElse(null)); // >>> null\n                    });\n\n            arsetArget3.block();",
      "section_id": "basic-usage"
    },
    {
      "id": "basic-usage-ex4",
      "language": "javascript",
      "code": "const setResult = await client.arSet('events:1', 0, ['login', 'click', 'purchase']);\nconsole.log(setResult); // >>> 3\n\nconst getResult = await client.arGet('events:1', 0);\nconsole.log(getResult); // >>> login\n\nconst missingResult = await client.arGet('events:1', 999);\nconsole.log(missingResult); // >>> null",
      "section_id": "basic-usage"
    },
    {
      "id": "basic-usage-ex5",
      "language": "php",
      "code": "$res1 = $redis->arset('events:1', 0, ['login', 'click', 'purchase']);\n        echo $res1 . PHP_EOL; // >>> 3\n\n        $res2 = $redis->arget('events:1', 0);\n        echo $res2 . PHP_EOL; // >>> login\n\n        $res3 = $redis->arget('events:1', 999);\n        echo var_export($res3, true) . PHP_EOL; // >>> NULL",
      "section_id": "basic-usage"
    },
    {
      "id": "basic-usage-ex6",
      "language": "python",
      "code": "res1 = r.arset(\"events:1\", 0, \"login\", \"click\", \"purchase\")\nprint(res1)\n# >>> 3\n\nres2 = r.arget(\"events:1\", 0)\nprint(res2)\n# >>> login\n\nres3 = r.arget(\"events:1\", 999)\nprint(res3)\n# >>> None",
      "section_id": "basic-usage"
    },
    {
      "id": "basic-usage-ex7",
      "language": "plaintext",
      "code": "> ARMSET metrics 0 \"10\" 5 \"20\" 100 \"30\"\n(integer) 3\n> ARMGET metrics 0 5 100 999\n1) \"10\"\n2) \"20\"\n3) \"30\"\n4) (nil)",
      "section_id": "basic-usage"
    },
    {
      "id": "basic-usage-ex8",
      "language": "go",
      "code": "msetRes, err := rdb.ARMSet(ctx, \"metrics\",\n\t\tredis.AREntry{Index: 0, Value: \"10\"},\n\t\tredis.AREntry{Index: 5, Value: \"20\"},\n\t\tredis.AREntry{Index: 100, Value: \"30\"},\n\t).Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(msetRes) // >>> 3\n\n\tmgetRes, err := rdb.ARMGet(ctx, \"metrics\", 0, 5, 100, 999).Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(mgetRes) // >>> [10 20 30 <nil>]",
      "section_id": "basic-usage"
    },
    {
      "id": "basic-usage-ex9",
      "language": "java",
      "code": "Map<Long, String> metricsValues = new HashMap<>();\n            metricsValues.put(0L, \"10\");\n            metricsValues.put(5L, \"20\");\n            metricsValues.put(100L, \"30\");\n\n            CompletableFuture<Void> armsetArmgetExample = asyncCommands\n                    .armset(\"metrics\", metricsValues)\n                    .thenCompose(res1 -> {\n                        System.out.println(res1);\n                        // >>> 3\n                        return asyncCommands.armget(\"metrics\", 0, 5, 100, 999);\n                    })\n                    .thenAccept(res2 -> {\n                        System.out.println(res2);\n                        // >>> [10, 20, 30, null]\n                    })\n                    .toCompletableFuture();\n\n            armsetArmgetExample.join();",
      "section_id": "basic-usage"
    },
    {
      "id": "basic-usage-ex10",
      "language": "java",
      "code": "Map<Long, String> armsetParams = new HashMap<>();\n            armsetParams.put(0L, \"10\");\n            armsetParams.put(5L, \"20\");\n            armsetParams.put(100L, \"30\");\n\n            Mono<Long> armsetArmget1 = reactiveCommands.armset(\"metrics\", armsetParams).doOnNext(result -> {\n                System.out.println(result); // >>> 3\n            });\n\n            armsetArmget1.block();\n\n            Mono<List<String>> armsetArmget2 = reactiveCommands.armget(\"metrics\", 0, 5, 100, 999)\n                    .collectList()\n                    .map(values -> values.stream()\n                            .map(value -> value.getValueOrElse(null))\n                            .collect(Collectors.toList()))\n                    .doOnNext(result -> {\n                        System.out.println(result); // >>> [10, 20, 30, null]\n                    });\n\n            armsetArmget2.block();",
      "section_id": "basic-usage"
    },
    {
      "id": "basic-usage-ex11",
      "language": "javascript",
      "code": "const mSetResult = await client.arMSet('metrics', { 0: '10', 5: '20', 100: '30' });\nconsole.log(mSetResult); // >>> 3\n\nconst mGetResult = await client.arMGet('metrics', [0, 5, 100, 999]);\nconsole.log(mGetResult); // >>> [ '10', '20', '30', null ]",
      "section_id": "basic-usage"
    },
    {
      "id": "basic-usage-ex12",
      "language": "php",
      "code": "$res1 = $redis->armset('metrics', [0 => '10', 5 => '20', 100 => '30']);\n        echo $res1 . PHP_EOL; // >>> 3\n\n        $res2 = $redis->armget('metrics', [0, 5, 100, 999]);\n        echo json_encode($res2) . PHP_EOL; // >>> [\"10\",\"20\",\"30\",null]",
      "section_id": "basic-usage"
    },
    {
      "id": "basic-usage-ex13",
      "language": "python",
      "code": "res4 = r.armset(\"metrics\", {0: \"10\", 5: \"20\", 100: \"30\"})\nprint(res4)\n# >>> 3\n\nres5 = r.armget(\"metrics\", 0, 5, 100, 999)\nprint(res5)\n# >>> ['10', '20', '30', None]",
      "section_id": "basic-usage"
    },
    {
      "id": "array-length-vs-element-count-ex0",
      "language": "plaintext",
      "code": "> ARSET sparse 0 \"a\"\n(integer) 1\n> ARSET sparse 1000000 \"b\"\n(integer) 1\n> ARLEN sparse\n(integer) 1000001\n> ARCOUNT sparse\n(integer) 2",
      "section_id": "array-length-vs-element-count"
    },
    {
      "id": "array-length-vs-element-count-ex1",
      "language": "go",
      "code": "set1, err := rdb.ARSet(ctx, \"sparse\", 0, \"a\").Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(set1) // >>> 1\n\n\tset2, err := rdb.ARSet(ctx, \"sparse\", 1000000, \"b\").Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(set2) // >>> 1\n\n\tlenRes, err := rdb.ARLen(ctx, \"sparse\").Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(lenRes) // >>> 1000001\n\n\tcountRes, err := rdb.ARCount(ctx, \"sparse\").Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(countRes) // >>> 2",
      "section_id": "array-length-vs-element-count"
    },
    {
      "id": "array-length-vs-element-count-ex2",
      "language": "java",
      "code": "CompletableFuture<Void> lenCountExample = asyncCommands\n                    .arset(\"sparse\", 0, \"a\")\n                    .thenCompose(res1 -> {\n                        System.out.println(res1);\n                        // >>> 1\n                        return asyncCommands.arset(\"sparse\", 1000000, \"b\");\n                    })\n                    .thenCompose(res2 -> {\n                        System.out.println(res2);\n                        // >>> 1\n                        return asyncCommands.arlen(\"sparse\");\n                    })\n                    .thenCompose(res3 -> {\n                        System.out.println(res3);\n                        // >>> 1000001\n                        return asyncCommands.arcount(\"sparse\");\n                    })\n                    .thenAccept(res4 -> {\n                        System.out.println(res4);\n                        // >>> 2\n                    })\n                    .toCompletableFuture();\n\n            lenCountExample.join();",
      "section_id": "array-length-vs-element-count"
    },
    {
      "id": "array-length-vs-element-count-ex3",
      "language": "java",
      "code": "Mono<Long> lenCount1 = reactiveCommands.arset(\"sparse\", 0, \"a\").doOnNext(result -> {\n                System.out.println(result); // >>> 1\n            });\n\n            lenCount1.block();\n\n            Mono<Long> lenCount2 = reactiveCommands.arset(\"sparse\", 1000000, \"b\").doOnNext(result -> {\n                System.out.println(result); // >>> 1\n            });\n\n            lenCount2.block();\n\n            Mono<Long> lenCount3 = reactiveCommands.arlen(\"sparse\").doOnNext(result -> {\n                System.out.println(result); // >>> 1000001\n            });\n\n            lenCount3.block();\n\n            Mono<Long> lenCount4 = reactiveCommands.arcount(\"sparse\").doOnNext(result -> {\n                System.out.println(result); // >>> 2\n            });\n\n            lenCount4.block();",
      "section_id": "array-length-vs-element-count"
    },
    {
      "id": "array-length-vs-element-count-ex4",
      "language": "javascript",
      "code": "const setA = await client.arSet('sparse', 0, 'a');\nconsole.log(setA); // >>> 1\n\nconst setB = await client.arSet('sparse', 1000000, 'b');\nconsole.log(setB); // >>> 1\n\nconst lenResult = await client.arLen('sparse');\nconsole.log(lenResult); // >>> 1000001\n\nconst countResult = await client.arCount('sparse');\nconsole.log(countResult); // >>> 2",
      "section_id": "array-length-vs-element-count"
    },
    {
      "id": "array-length-vs-element-count-ex5",
      "language": "php",
      "code": "$res1 = $redis->arset('sparse', 0, 'a');\n        echo $res1 . PHP_EOL; // >>> 1\n\n        $res2 = $redis->arset('sparse', 1000000, 'b');\n        echo $res2 . PHP_EOL; // >>> 1\n\n        $res3 = $redis->arlen('sparse');\n        echo $res3 . PHP_EOL; // >>> 1000001\n\n        $res4 = $redis->arcount('sparse');\n        echo $res4 . PHP_EOL; // >>> 2",
      "section_id": "array-length-vs-element-count"
    },
    {
      "id": "array-length-vs-element-count-ex6",
      "language": "python",
      "code": "res6 = r.arset(\"sparse\", 0, \"a\")\nprint(res6)\n# >>> 1\n\nres7 = r.arset(\"sparse\", 1000000, \"b\")\nprint(res7)\n# >>> 1\n\nres8 = r.arlen(\"sparse\")\nprint(res8)\n# >>> 1000001\n\nres9 = r.arcount(\"sparse\")\nprint(res9)\n# >>> 2",
      "section_id": "array-length-vs-element-count"
    },
    {
      "id": "reading-ranges-ex0",
      "language": "plaintext",
      "code": "> ARMSET seq 0 \"a\" 1 \"b\" 3 \"d\"\n(integer) 3\n> ARGETRANGE seq 0 3\n1) \"a\"\n2) \"b\"\n3) (nil)\n4) \"d\"",
      "section_id": "reading-ranges"
    },
    {
      "id": "reading-ranges-ex1",
      "language": "go",
      "code": "msetRes, err := rdb.ARMSet(ctx, \"seq\",\n\t\tredis.AREntry{Index: 0, Value: \"a\"},\n\t\tredis.AREntry{Index: 1, Value: \"b\"},\n\t\tredis.AREntry{Index: 3, Value: \"d\"},\n\t).Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(msetRes) // >>> 3\n\n\trangeRes, err := rdb.ARGetRange(ctx, \"seq\", 0, 3).Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(rangeRes) // >>> [a b <nil> d]",
      "section_id": "reading-ranges"
    },
    {
      "id": "reading-ranges-ex2",
      "language": "java",
      "code": "Map<Long, String> seqRangeValues = new HashMap<>();\n            seqRangeValues.put(0L, \"a\");\n            seqRangeValues.put(1L, \"b\");\n            seqRangeValues.put(3L, \"d\");\n\n            CompletableFuture<Void> argetrangeExample = asyncCommands\n                    .armset(\"seq\", seqRangeValues)\n                    .thenCompose(res1 -> {\n                        System.out.println(res1);\n                        // >>> 3\n                        return asyncCommands.argetrange(\"seq\", 0, 3);\n                    })\n                    .thenAccept(res2 -> {\n                        System.out.println(res2);\n                        // >>> [a, b, null, d]\n                    })\n                    .toCompletableFuture();\n\n            argetrangeExample.join();",
      "section_id": "reading-ranges"
    },
    {
      "id": "reading-ranges-ex3",
      "language": "java",
      "code": "Map<Long, String> argetrangeParams = new HashMap<>();\n            argetrangeParams.put(0L, \"a\");\n            argetrangeParams.put(1L, \"b\");\n            argetrangeParams.put(3L, \"d\");\n\n            Mono<Long> argetrange1 = reactiveCommands.armset(\"seq\", argetrangeParams).doOnNext(result -> {\n                System.out.println(result); // >>> 3\n            });\n\n            argetrange1.block();\n\n            Mono<List<String>> argetrange2 = reactiveCommands.argetrange(\"seq\", 0, 3)\n                    .collectList()\n                    .map(values -> values.stream()\n                            .map(value -> value.getValueOrElse(null))\n                            .collect(Collectors.toList()))\n                    .doOnNext(result -> {\n                        System.out.println(result); // >>> [a, b, null, d]\n                    });\n\n            argetrange2.block();",
      "section_id": "reading-ranges"
    },
    {
      "id": "reading-ranges-ex4",
      "language": "javascript",
      "code": "const rangeSetResult = await client.arMSet('seq', { 0: 'a', 1: 'b', 3: 'd' });\nconsole.log(rangeSetResult); // >>> 3\n\nconst rangeResult = await client.arGetRange('seq', 0, 3);\nconsole.log(rangeResult); // >>> [ 'a', 'b', null, 'd' ]",
      "section_id": "reading-ranges"
    },
    {
      "id": "reading-ranges-ex5",
      "language": "php",
      "code": "$res1 = $redis->armset('seq', [0 => 'a', 1 => 'b', 3 => 'd']);\n        echo $res1 . PHP_EOL; // >>> 3\n\n        $res2 = $redis->argetrange('seq', 0, 3);\n        echo json_encode($res2) . PHP_EOL; // >>> [\"a\",\"b\",null,\"d\"]",
      "section_id": "reading-ranges"
    },
    {
      "id": "reading-ranges-ex6",
      "language": "python",
      "code": "res10 = r.armset(\"seq\", {0: \"a\", 1: \"b\", 3: \"d\"})\nprint(res10)\n# >>> 3\n\nres11 = r.argetrange(\"seq\", 0, 3)\nprint(res11)\n# >>> ['a', 'b', None, 'd']",
      "section_id": "reading-ranges"
    },
    {
      "id": "reading-ranges-ex7",
      "language": "plaintext",
      "code": "> ARSCAN seq 0 3\n1) 1) (integer) 0\n   2) \"a\"\n2) 1) (integer) 1\n   2) \"b\"\n3) 1) (integer) 3\n   2) \"d\"",
      "section_id": "reading-ranges"
    },
    {
      "id": "reading-ranges-ex8",
      "language": "go",
      "code": "msetRes, err := rdb.ARMSet(ctx, \"seq\",\n\t\tredis.AREntry{Index: 0, Value: \"a\"},\n\t\tredis.AREntry{Index: 1, Value: \"b\"},\n\t\tredis.AREntry{Index: 3, Value: \"d\"},\n\t).Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(msetRes) // >>> 3\n\n\tscanRes, err := rdb.ARScan(ctx, \"seq\", 0, 3, nil).Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfor _, entry := range scanRes {\n\t\tfmt.Printf(\"%d -> %s\\n\", entry.Index, entry.Value)\n\t}\n\t// >>> 0 -> a\n\t// >>> 1 -> b\n\t// >>> 3 -> d",
      "section_id": "reading-ranges"
    },
    {
      "id": "reading-ranges-ex9",
      "language": "java",
      "code": "Map<Long, String> seqScanValues = new HashMap<>();\n            seqScanValues.put(0L, \"a\");\n            seqScanValues.put(1L, \"b\");\n            seqScanValues.put(3L, \"d\");\n\n            CompletableFuture<Void> arscanExample = asyncCommands\n                    .armset(\"seq\", seqScanValues)\n                    .thenCompose(res1 -> {\n                        System.out.println(res1);\n                        // >>> 3\n                        return asyncCommands.arscan(\"seq\", 0, 3);\n                    })\n                    .thenAccept(res2 -> {\n                        for (IndexedValue<String> pair : res2) {\n                            System.out.println(pair.getIndex() + \" -> \" + pair.getValue());\n                        }\n                        // >>> 0 -> a\n                        // >>> 1 -> b\n                        // >>> 3 -> d\n                    })\n                    .toCompletableFuture();\n\n            arscanExample.join();",
      "section_id": "reading-ranges"
    },
    {
      "id": "reading-ranges-ex10",
      "language": "java",
      "code": "Map<Long, String> arscanParams = new HashMap<>();\n            arscanParams.put(0L, \"a\");\n            arscanParams.put(1L, \"b\");\n            arscanParams.put(3L, \"d\");\n\n            Mono<Long> arscan1 = reactiveCommands.armset(\"seq\", arscanParams).doOnNext(result -> {\n                System.out.println(result); // >>> 3\n            });\n\n            arscan1.block();\n\n            Mono<List<IndexedValue<String>>> arscan2 = reactiveCommands.arscan(\"seq\", 0, 3)\n                    .doOnNext(entry -> {\n                        System.out.println(entry.getIndex() + \" -> \" + entry.getValue());\n                        // >>> 0 -> a\n                        // >>> 1 -> b\n                        // >>> 3 -> d\n                    })\n                    .collectList()\n            ;\n\n            arscan2.block();",
      "section_id": "reading-ranges"
    },
    {
      "id": "reading-ranges-ex11",
      "language": "javascript",
      "code": "const scanSetResult = await client.arMSet('seq', { 0: 'a', 1: 'b', 3: 'd' });\nconsole.log(scanSetResult); // >>> 3\n\nconst scanResult = await client.arScan('seq', 0, 3);\nfor (const { index, value } of scanResult) {\n  console.log(`${index} -> ${value}`);\n}\n// >>> 0 -> a\n// >>> 1 -> b\n// >>> 3 -> d",
      "section_id": "reading-ranges"
    },
    {
      "id": "reading-ranges-ex12",
      "language": "php",
      "code": "$res1 = $redis->armset('seq', [0 => 'a', 1 => 'b', 3 => 'd']);\n        echo $res1 . PHP_EOL; // >>> 3\n\n        $res2 = $redis->arscan('seq', 0, 3);\n        foreach ($res2 as $pair) {\n            echo $pair[0] . ' -> ' . $pair[1] . PHP_EOL;\n        }\n        // >>> 0 -> a\n        // >>> 1 -> b\n        // >>> 3 -> d",
      "section_id": "reading-ranges"
    },
    {
      "id": "reading-ranges-ex13",
      "language": "python",
      "code": "res12 = r.armset(\"seq\", {0: \"a\", 1: \"b\", 3: \"d\"})\nprint(res12)\n# >>> 3\n\nres13 = r.arscan(\"seq\", 0, 3)\nfor index, value in res13:\n    print(f\"{index} -> {value}\")\n# >>> 0 -> a\n# >>> 1 -> b\n# >>> 3 -> d",
      "section_id": "reading-ranges"
    },
    {
      "id": "sequential-insertion-ex0",
      "language": "plaintext",
      "code": "> ARINSERT log \"event1\"\n(integer) 0\n> ARINSERT log \"event2\"\n(integer) 1\n> ARNEXT log\n(integer) 2\n> ARSEEK log 10\n(integer) 1\n> ARINSERT log \"event3\"\n(integer) 10",
      "section_id": "sequential-insertion"
    },
    {
      "id": "sequential-insertion-ex1",
      "language": "go",
      "code": "ins1, err := rdb.ARInsert(ctx, \"log\", \"event1\").Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(ins1) // >>> 0\n\n\tins2, err := rdb.ARInsert(ctx, \"log\", \"event2\").Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(ins2) // >>> 1\n\n\tnextRes, err := rdb.ARNext(ctx, \"log\").Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(nextRes) // >>> 2\n\n\tseekRes, err := rdb.ARSeek(ctx, \"log\", 10).Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(seekRes) // >>> 1\n\n\tins3, err := rdb.ARInsert(ctx, \"log\", \"event3\").Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(ins3) // >>> 10",
      "section_id": "sequential-insertion"
    },
    {
      "id": "sequential-insertion-ex2",
      "language": "java",
      "code": "CompletableFuture<Void> arinsertExample = asyncCommands\n                    .arinsert(\"log\", \"event1\")\n                    .thenCompose(res1 -> {\n                        System.out.println(res1);\n                        // >>> 0\n                        return asyncCommands.arinsert(\"log\", \"event2\");\n                    })\n                    .thenCompose(res2 -> {\n                        System.out.println(res2);\n                        // >>> 1\n                        return asyncCommands.arnext(\"log\");\n                    })\n                    .thenCompose(res3 -> {\n                        System.out.println(res3);\n                        // >>> 2\n                        return asyncCommands.arseek(\"log\", 10);\n                    })\n                    .thenCompose(res4 -> {\n                        System.out.println(res4);\n                        // >>> 1\n                        return asyncCommands.arinsert(\"log\", \"event3\");\n                    })\n                    .thenAccept(res5 -> {\n                        System.out.println(res5);\n                        // >>> 10\n                    })\n                    .toCompletableFuture();\n\n            arinsertExample.join();",
      "section_id": "sequential-insertion"
    },
    {
      "id": "sequential-insertion-ex3",
      "language": "java",
      "code": "Mono<Long> arinsert1 = reactiveCommands.arinsert(\"log\", \"event1\").doOnNext(result -> {\n                System.out.println(result); // >>> 0\n            });\n\n            arinsert1.block();\n\n            Mono<Long> arinsert2 = reactiveCommands.arinsert(\"log\", \"event2\").doOnNext(result -> {\n                System.out.println(result); // >>> 1\n            });\n\n            arinsert2.block();\n\n            Mono<Long> arinsert3 = reactiveCommands.arnext(\"log\").doOnNext(result -> {\n                System.out.println(result); // >>> 2\n            });\n\n            arinsert3.block();\n\n            Mono<Long> arinsert4 = reactiveCommands.arseek(\"log\", 10).doOnNext(result -> {\n                System.out.println(result); // >>> 1\n            });\n\n            arinsert4.block();\n\n            Mono<Long> arinsert5 = reactiveCommands.arinsert(\"log\", \"event3\").doOnNext(result -> {\n                System.out.println(result); // >>> 10\n            });\n\n            arinsert5.block();",
      "section_id": "sequential-insertion"
    },
    {
      "id": "sequential-insertion-ex4",
      "language": "javascript",
      "code": "const insert1 = await client.arInsert('log', 'event1');\nconsole.log(insert1); // >>> 0\n\nconst insert2 = await client.arInsert('log', 'event2');\nconsole.log(insert2); // >>> 1\n\nconst nextResult = await client.arNext('log');\nconsole.log(nextResult); // >>> 2\n\nconst seekResult = await client.arSeek('log', 10);\nconsole.log(seekResult); // >>> 1\n\nconst insert3 = await client.arInsert('log', 'event3');\nconsole.log(insert3); // >>> 10",
      "section_id": "sequential-insertion"
    },
    {
      "id": "sequential-insertion-ex5",
      "language": "php",
      "code": "$res1 = $redis->arinsert('log', 'event1');\n        echo $res1 . PHP_EOL; // >>> 0\n\n        $res2 = $redis->arinsert('log', 'event2');\n        echo $res2 . PHP_EOL; // >>> 1\n\n        $res3 = $redis->arnext('log');\n        echo $res3 . PHP_EOL; // >>> 2\n\n        $res4 = $redis->arseek('log', 10);\n        echo $res4 . PHP_EOL; // >>> 1\n\n        $res5 = $redis->arinsert('log', 'event3');\n        echo $res5 . PHP_EOL; // >>> 10",
      "section_id": "sequential-insertion"
    },
    {
      "id": "sequential-insertion-ex6",
      "language": "python",
      "code": "res14 = r.arinsert(\"log\", \"event1\")\nprint(res14)\n# >>> 0\n\nres15 = r.arinsert(\"log\", \"event2\")\nprint(res15)\n# >>> 1\n\nres16 = r.arnext(\"log\")\nprint(res16)\n# >>> 2\n\nres17 = r.arseek(\"log\", 10)\nprint(res17)\n# >>> 1\n\nres18 = r.arinsert(\"log\", \"event3\")\nprint(res18)\n# >>> 10",
      "section_id": "sequential-insertion"
    },
    {
      "id": "ring-buffer-mode-ex0",
      "language": "plaintext",
      "code": "> ARRING readings 3 \"v0\"\n(integer) 0\n> ARRING readings 3 \"v1\"\n(integer) 1\n> ARRING readings 3 \"v2\"\n(integer) 2\n> ARRING readings 3 \"v3\"\n(integer) 0\n> ARGET readings 0\n\"v3\"",
      "section_id": "ring-buffer-mode"
    },
    {
      "id": "ring-buffer-mode-ex1",
      "language": "go",
      "code": "ring0, err := rdb.ARRing(ctx, \"readings\", 3, \"v0\").Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(ring0) // >>> 0\n\n\tring1, err := rdb.ARRing(ctx, \"readings\", 3, \"v1\").Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(ring1) // >>> 1\n\n\tring2, err := rdb.ARRing(ctx, \"readings\", 3, \"v2\").Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(ring2) // >>> 2\n\n\tring3, err := rdb.ARRing(ctx, \"readings\", 3, \"v3\").Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(ring3) // >>> 0\n\n\tgetRes, err := rdb.ARGet(ctx, \"readings\", 0).Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(getRes) // >>> v3",
      "section_id": "ring-buffer-mode"
    },
    {
      "id": "ring-buffer-mode-ex2",
      "language": "java",
      "code": "CompletableFuture<Void> arringExample = asyncCommands\n                    .arring(\"readings\", 3, \"v0\")\n                    .thenCompose(res1 -> {\n                        System.out.println(res1);\n                        // >>> 0\n                        return asyncCommands.arring(\"readings\", 3, \"v1\");\n                    })\n                    .thenCompose(res2 -> {\n                        System.out.println(res2);\n                        // >>> 1\n                        return asyncCommands.arring(\"readings\", 3, \"v2\");\n                    })\n                    .thenCompose(res3 -> {\n                        System.out.println(res3);\n                        // >>> 2\n                        return asyncCommands.arring(\"readings\", 3, \"v3\");\n                    })\n                    .thenCompose(res4 -> {\n                        System.out.println(res4);\n                        // >>> 0\n                        return asyncCommands.arget(\"readings\", 0);\n                    })\n                    .thenAccept(res5 -> {\n                        System.out.println(res5);\n                        // >>> v3\n                    })\n                    .toCompletableFuture();\n\n            arringExample.join();",
      "section_id": "ring-buffer-mode"
    },
    {
      "id": "ring-buffer-mode-ex3",
      "language": "java",
      "code": "Mono<Long> arring1 = reactiveCommands.arring(\"readings\", 3, \"v0\").doOnNext(result -> {\n                System.out.println(result); // >>> 0\n            });\n\n            arring1.block();\n\n            Mono<Long> arring2 = reactiveCommands.arring(\"readings\", 3, \"v1\").doOnNext(result -> {\n                System.out.println(result); // >>> 1\n            });\n\n            arring2.block();\n\n            Mono<Long> arring3 = reactiveCommands.arring(\"readings\", 3, \"v2\").doOnNext(result -> {\n                System.out.println(result); // >>> 2\n            });\n\n            arring3.block();\n\n            Mono<Long> arring4 = reactiveCommands.arring(\"readings\", 3, \"v3\").doOnNext(result -> {\n                System.out.println(result); // >>> 0\n            });\n\n            arring4.block();\n\n            Mono<String> arring5 = reactiveCommands.arget(\"readings\", 0).doOnNext(result -> {\n                System.out.println(result); // >>> v3\n            });\n\n            arring5.block();",
      "section_id": "ring-buffer-mode"
    },
    {
      "id": "ring-buffer-mode-ex4",
      "language": "javascript",
      "code": "const ring0 = await client.arRing('readings', 3, 'v0');\nconsole.log(ring0); // >>> 0\n\nconst ring1 = await client.arRing('readings', 3, 'v1');\nconsole.log(ring1); // >>> 1\n\nconst ring2 = await client.arRing('readings', 3, 'v2');\nconsole.log(ring2); // >>> 2\n\nconst ring3 = await client.arRing('readings', 3, 'v3');\nconsole.log(ring3); // >>> 0\n\nconst ringGet = await client.arGet('readings', 0);\nconsole.log(ringGet); // >>> v3",
      "section_id": "ring-buffer-mode"
    },
    {
      "id": "ring-buffer-mode-ex5",
      "language": "php",
      "code": "$res1 = $redis->arring('readings', 3, 'v0');\n        echo $res1 . PHP_EOL; // >>> 0\n\n        $res2 = $redis->arring('readings', 3, 'v1');\n        echo $res2 . PHP_EOL; // >>> 1\n\n        $res3 = $redis->arring('readings', 3, 'v2');\n        echo $res3 . PHP_EOL; // >>> 2\n\n        $res4 = $redis->arring('readings', 3, 'v3');\n        echo $res4 . PHP_EOL; // >>> 0\n\n        $res5 = $redis->arget('readings', 0);\n        echo $res5 . PHP_EOL; // >>> v3",
      "section_id": "ring-buffer-mode"
    },
    {
      "id": "ring-buffer-mode-ex6",
      "language": "python",
      "code": "res19 = r.arring(\"readings\", 3, \"v0\")\nprint(res19)\n# >>> 0\n\nres20 = r.arring(\"readings\", 3, \"v1\")\nprint(res20)\n# >>> 1\n\nres21 = r.arring(\"readings\", 3, \"v2\")\nprint(res21)\n# >>> 2\n\nres22 = r.arring(\"readings\", 3, \"v3\")\nprint(res22)\n# >>> 0\n\nres23 = r.arget(\"readings\", 0)\nprint(res23)\n# >>> v3",
      "section_id": "ring-buffer-mode"
    },
    {
      "id": "ring-buffer-mode-ex7",
      "language": "plaintext",
      "code": "> ARLASTITEMS readings 3\n1) \"v1\"\n2) \"v2\"\n3) \"v3\"\n> ARLASTITEMS readings 3 REV\n1) \"v3\"\n2) \"v2\"\n3) \"v1\"",
      "section_id": "ring-buffer-mode"
    },
    {
      "id": "ring-buffer-mode-ex8",
      "language": "go",
      "code": "// Set up the ring: insert v0, v1, v2, v3 into a size-3 ring.\n\tfor _, v := range []string{\"v0\", \"v1\", \"v2\", \"v3\"} {\n\t\tif err := rdb.ARRing(ctx, \"readings\", 3, v).Err(); err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t}\n\n\tlastRes, err := rdb.ARLastItems(ctx, \"readings\", 3, false).Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(lastRes) // >>> [v1 v2 v3]\n\n\tlastRevRes, err := rdb.ARLastItems(ctx, \"readings\", 3, true).Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(lastRevRes) // >>> [v3 v2 v1]",
      "section_id": "ring-buffer-mode"
    },
    {
      "id": "ring-buffer-mode-ex9",
      "language": "java",
      "code": "CompletableFuture<Void> arlastitemsExample = asyncCommands\n                    .arring(\"readings\", 3, \"v0\")\n                    .thenCompose(res1 -> asyncCommands.arring(\"readings\", 3, \"v1\"))\n                    .thenCompose(res2 -> asyncCommands.arring(\"readings\", 3, \"v2\"))\n                    .thenCompose(res3 -> asyncCommands.arring(\"readings\", 3, \"v3\"))\n                    .thenCompose(res4 -> asyncCommands.arlastitems(\"readings\", 3))\n                    .thenCompose(res5 -> {\n                        System.out.println(res5);\n                        // >>> [v1, v2, v3]\n                        return asyncCommands.arlastitems(\"readings\", 3, true);\n                    })\n                    .thenAccept(res6 -> {\n                        System.out.println(res6);\n                        // >>> [v3, v2, v1]\n                    })\n                    .toCompletableFuture();\n\n            arlastitemsExample.join();",
      "section_id": "ring-buffer-mode"
    },
    {
      "id": "ring-buffer-mode-ex10",
      "language": "java",
      "code": "// Set up the ring: insert v0, v1, v2, v3 into a size-3 ring.\n            reactiveCommands.arring(\"readings\", 3, \"v0\").block();\n            reactiveCommands.arring(\"readings\", 3, \"v1\").block();\n            reactiveCommands.arring(\"readings\", 3, \"v2\").block();\n            reactiveCommands.arring(\"readings\", 3, \"v3\").block();\n\n            Mono<List<String>> arlastitems1 = reactiveCommands.arlastitems(\"readings\", 3).collectList()\n                    .doOnNext(result -> {\n                        System.out.println(result); // >>> [v1, v2, v3]\n                    });\n\n            arlastitems1.block();\n\n            Mono<List<String>> arlastitems2 = reactiveCommands.arlastitems(\"readings\", 3, true).collectList()\n                    .doOnNext(result -> {\n                        System.out.println(result); // >>> [v3, v2, v1]\n                    });\n\n            arlastitems2.block();",
      "section_id": "ring-buffer-mode"
    },
    {
      "id": "ring-buffer-mode-ex11",
      "language": "javascript",
      "code": "await client.arRing('readings', 3, 'v0');\nawait client.arRing('readings', 3, 'v1');\nawait client.arRing('readings', 3, 'v2');\nawait client.arRing('readings', 3, 'v3');\n\nconst lastItems = await client.arLastItems('readings', 3);\nconsole.log(lastItems); // >>> [ 'v1', 'v2', 'v3' ]\n\nconst lastItemsRev = await client.arLastItems('readings', 3, { REV: true });\nconsole.log(lastItemsRev); // >>> [ 'v3', 'v2', 'v1' ]",
      "section_id": "ring-buffer-mode"
    },
    {
      "id": "ring-buffer-mode-ex12",
      "language": "php",
      "code": "$redis->arring('readings', 3, 'v0');\n        $redis->arring('readings', 3, 'v1');\n        $redis->arring('readings', 3, 'v2');\n        $redis->arring('readings', 3, 'v3');\n\n        $res1 = $redis->arlastitems('readings', 3);\n        echo json_encode($res1) . PHP_EOL; // >>> [\"v1\",\"v2\",\"v3\"]\n\n        $res2 = $redis->arlastitems('readings', 3, true);\n        echo json_encode($res2) . PHP_EOL; // >>> [\"v3\",\"v2\",\"v1\"]",
      "section_id": "ring-buffer-mode"
    },
    {
      "id": "ring-buffer-mode-ex13",
      "language": "python",
      "code": "r.arring(\"readings\", 3, \"v0\")\nr.arring(\"readings\", 3, \"v1\")\nr.arring(\"readings\", 3, \"v2\")\nr.arring(\"readings\", 3, \"v3\")\n\nres24 = r.arlastitems(\"readings\", 3)\nprint(res24)\n# >>> ['v1', 'v2', 'v3']\n\nres25 = r.arlastitems(\"readings\", 3, rev=True)\nprint(res25)\n# >>> ['v3', 'v2', 'v1']",
      "section_id": "ring-buffer-mode"
    },
    {
      "id": "aggregate-operations-ex0",
      "language": "plaintext",
      "code": "> ARMSET scores 0 \"10\" 1 \"20\" 2 \"30\"\n(integer) 3\n> AROP scores 0 2 SUM\n\"60\"\n> AROP scores 0 2 MAX\n\"30\"\n> AROP scores 0 2 MATCH \"10\"\n(integer) 1",
      "section_id": "aggregate-operations"
    },
    {
      "id": "aggregate-operations-ex1",
      "language": "go",
      "code": "msetRes, err := rdb.ARMSet(ctx, \"scores\",\n\t\tredis.AREntry{Index: 0, Value: \"10\"},\n\t\tredis.AREntry{Index: 1, Value: \"20\"},\n\t\tredis.AREntry{Index: 2, Value: \"30\"},\n\t).Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(msetRes) // >>> 3\n\n\tsumRes, err := rdb.AROpSum(ctx, \"scores\", 0, 2).Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(sumRes) // >>> 60\n\n\tmaxRes, err := rdb.AROpMax(ctx, \"scores\", 0, 2).Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(maxRes) // >>> 30\n\n\tmatchRes, err := rdb.AROpMatch(ctx, \"scores\", 0, 2, \"10\").Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(matchRes) // >>> 1",
      "section_id": "aggregate-operations"
    },
    {
      "id": "aggregate-operations-ex2",
      "language": "java",
      "code": "Map<Long, String> aropScores = new HashMap<>();\n            aropScores.put(0L, \"10\");\n            aropScores.put(1L, \"20\");\n            aropScores.put(2L, \"30\");\n\n            CompletableFuture<Void> aropExample = asyncCommands\n                    .armset(\"scores\", aropScores)\n                    .thenCompose(res1 -> {\n                        System.out.println(res1);\n                        // >>> 3\n                        return asyncCommands.aropAggregate(\"scores\", 0, 2, ArAggregateType.SUM);\n                    })\n                    .thenCompose(res2 -> {\n                        System.out.println(res2);\n                        // >>> 60\n                        return asyncCommands.aropAggregate(\"scores\", 0, 2, ArAggregateType.MAX);\n                    })\n                    .thenCompose(res3 -> {\n                        System.out.println(res3);\n                        // >>> 30\n                        return asyncCommands.aropCount(\"scores\", 0, 2, \"10\");\n                    })\n                    .thenAccept(res4 -> {\n                        System.out.println(res4);\n                        // >>> 1\n                    })\n                    .toCompletableFuture();\n\n            aropExample.join();",
      "section_id": "aggregate-operations"
    },
    {
      "id": "aggregate-operations-ex3",
      "language": "java",
      "code": "Map<Long, String> aropParams = new HashMap<>();\n            aropParams.put(0L, \"10\");\n            aropParams.put(1L, \"20\");\n            aropParams.put(2L, \"30\");\n\n            Mono<Long> arop1 = reactiveCommands.armset(\"scores\", aropParams).doOnNext(result -> {\n                System.out.println(result); // >>> 3\n            });\n\n            arop1.block();\n\n            Mono<String> arop2 = reactiveCommands.aropAggregate(\"scores\", 0, 2, ArAggregateType.SUM)\n                    .doOnNext(result -> {\n                        System.out.println(result); // >>> 60\n                    });\n\n            arop2.block();\n\n            Mono<String> arop3 = reactiveCommands.aropAggregate(\"scores\", 0, 2, ArAggregateType.MAX)\n                    .doOnNext(result -> {\n                        System.out.println(result); // >>> 30\n                    });\n\n            arop3.block();\n\n            Mono<Long> arop4 = reactiveCommands.aropCount(\"scores\", 0, 2, \"10\").doOnNext(result -> {\n                System.out.println(result); // >>> 1\n            });\n\n            arop4.block();",
      "section_id": "aggregate-operations"
    },
    {
      "id": "aggregate-operations-ex4",
      "language": "javascript",
      "code": "const opSetResult = await client.arMSet('scores', { 0: '10', 1: '20', 2: '30' });\nconsole.log(opSetResult); // >>> 3\n\nconst sumResult = await client.arOp('scores', 0, 2, 'SUM');\nconsole.log(sumResult); // >>> 60\n\nconst maxResult = await client.arOp('scores', 0, 2, 'MAX');\nconsole.log(maxResult); // >>> 30\n\nconst matchResult = await client.arOp('scores', 0, 2, 'MATCH', '10');\nconsole.log(matchResult); // >>> 1",
      "section_id": "aggregate-operations"
    },
    {
      "id": "aggregate-operations-ex5",
      "language": "php",
      "code": "$res1 = $redis->armset('scores', [0 => '10', 1 => '20', 2 => '30']);\n        echo $res1 . PHP_EOL; // >>> 3\n\n        $res2 = $redis->arop('scores', 0, 2, 'SUM');\n        echo $res2 . PHP_EOL; // >>> 60\n\n        $res3 = $redis->arop('scores', 0, 2, 'MAX');\n        echo $res3 . PHP_EOL; // >>> 30\n\n        $res4 = $redis->arop('scores', 0, 2, 'MATCH', '10');\n        echo $res4 . PHP_EOL; // >>> 1",
      "section_id": "aggregate-operations"
    },
    {
      "id": "aggregate-operations-ex6",
      "language": "python",
      "code": "res26 = r.armset(\"scores\", {0: \"10\", 1: \"20\", 2: \"30\"})\nprint(res26)\n# >>> 3\n\nres27 = r.arop(\"scores\", 0, 2, ArrayAggregateOperations.SUM)\nprint(res27)\n# >>> 60\n\nres28 = r.arop(\"scores\", 0, 2, ArrayAggregateOperations.MAX)\nprint(res28)\n# >>> 30\n\nres29 = r.arop(\"scores\", 0, 2, ArrayAggregateOperations.MATCH, value=\"10\")\nprint(res29)\n# >>> 1",
      "section_id": "aggregate-operations"
    },
    {
      "id": "searching-elements-ex0",
      "language": "plaintext",
      "code": "> DEL log\n(integer) 1\n> ARMSET log 0 \"boot: ok\" 1 \"warn: disk\" 2 \"ERROR: cpu\" 3 \"info: ready\" 4 \"error: net\"\n(integer) 5\n> ARGREP log - + MATCH \"error\" NOCASE\n1) (integer) 2\n2) (integer) 4\n> ARGREP log 0 4 GLOB \"warn:*\" OR GLOB \"error:*\" WITHVALUES\n1) 1) (integer) 1\n   2) \"warn: disk\"\n2) 1) (integer) 4\n   2) \"error: net\"",
      "section_id": "searching-elements"
    },
    {
      "id": "searching-elements-ex1",
      "language": "go",
      "code": "msetRes, err := rdb.ARMSet(ctx, \"log\",\n\t\tredis.AREntry{Index: 0, Value: \"boot: ok\"},\n\t\tredis.AREntry{Index: 1, Value: \"warn: disk\"},\n\t\tredis.AREntry{Index: 2, Value: \"ERROR: cpu\"},\n\t\tredis.AREntry{Index: 3, Value: \"info: ready\"},\n\t\tredis.AREntry{Index: 4, Value: \"error: net\"},\n\t).Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(msetRes) // >>> 5\n\n\t// Case-insensitive match for \"error\".\n\tgrepRes, err := rdb.ARGrep(ctx, \"log\", \"0\", \"4\", &redis.ARGrepArgs{\n\t\tPredicates: []redis.ARGrepPredicate{\n\t\t\t{Type: redis.ARGrepMatch, Value: \"error\"},\n\t\t},\n\t\tNoCase: true,\n\t}).Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(grepRes) // >>> [2 4]\n\n\t// Two GLOB predicates combined with the default OR, returning values too.\n\tgrepValsRes, err := rdb.ARGrepWithValues(ctx, \"log\", \"0\", \"4\", &redis.ARGrepArgs{\n\t\tPredicates: []redis.ARGrepPredicate{\n\t\t\t{Type: redis.ARGrepGlob, Value: \"warn:*\"},\n\t\t\t{Type: redis.ARGrepGlob, Value: \"error:*\"},\n\t\t},\n\t}).Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfor _, entry := range grepValsRes {\n\t\tfmt.Printf(\"%d -> %s\\n\", entry.Index, entry.Value)\n\t}\n\t// >>> 1 -> warn: disk\n\t// >>> 4 -> error: net",
      "section_id": "searching-elements"
    },
    {
      "id": "searching-elements-ex2",
      "language": "java",
      "code": "Map<Long, String> argrepLog = new HashMap<>();\n            argrepLog.put(0L, \"boot: ok\");\n            argrepLog.put(1L, \"warn: disk\");\n            argrepLog.put(2L, \"ERROR: cpu\");\n            argrepLog.put(3L, \"info: ready\");\n            argrepLog.put(4L, \"error: net\");\n\n            CompletableFuture<Void> argrepExample = asyncCommands\n                    .armset(\"log\", argrepLog)\n                    .thenCompose(res1 -> {\n                        System.out.println(res1);\n                        // >>> 5\n                        return asyncCommands.argrep(\"log\",\n                                ArGrepArgs.range(0, 4).match(\"error\").nocase());\n                    })\n                    .thenCompose(res2 -> {\n                        System.out.println(res2);\n                        // >>> [2, 4]\n                        return asyncCommands.argrepWithValues(\"log\",\n                                ArGrepArgs.range(0, 4).glob(\"warn:*\").glob(\"error:*\"));\n                    })\n                    .thenAccept(res3 -> {\n                        for (IndexedValue<String> pair : res3) {\n                            System.out.println(pair.getIndex() + \" -> \" + pair.getValue());\n                        }\n                        // >>> 1 -> warn: disk\n                        // >>> 4 -> error: net\n                    })\n                    .toCompletableFuture();\n\n            argrepExample.join();",
      "section_id": "searching-elements"
    },
    {
      "id": "searching-elements-ex3",
      "language": "java",
      "code": "Map<Long, String> argrepParams = new HashMap<>();\n            argrepParams.put(0L, \"boot: ok\");\n            argrepParams.put(1L, \"warn: disk\");\n            argrepParams.put(2L, \"ERROR: cpu\");\n            argrepParams.put(3L, \"info: ready\");\n            argrepParams.put(4L, \"error: net\");\n\n            Mono<Long> argrep1 = reactiveCommands.armset(\"log\", argrepParams).doOnNext(result -> {\n                System.out.println(result); // >>> 5\n            });\n\n            argrep1.block();\n\n            Mono<List<Long>> argrep2 = reactiveCommands.argrep(\"log\", ArGrepArgs.range(0, 4).match(\"error\").nocase())\n                    .collectList()\n                    .doOnNext(result -> {\n                        System.out.println(result); // >>> [2, 4]\n                    });\n\n            argrep2.block();\n\n            Mono<List<IndexedValue<String>>> argrep3 = reactiveCommands\n                    .argrepWithValues(\"log\", ArGrepArgs.range(0, 4).glob(\"warn:*\").glob(\"error:*\"))\n                    .doOnNext(entry -> {\n                        System.out.println(entry.getIndex() + \" -> \" + entry.getValue());\n                        // >>> 1 -> warn: disk\n                        // >>> 4 -> error: net\n                    })\n                    .collectList()\n            ;\n\n            argrep3.block();",
      "section_id": "searching-elements"
    },
    {
      "id": "searching-elements-ex4",
      "language": "javascript",
      "code": "const grepSetResult = await client.arMSet('log', {\n  0: 'boot: ok',\n  1: 'warn: disk',\n  2: 'ERROR: cpu',\n  3: 'info: ready',\n  4: 'error: net'\n});\nconsole.log(grepSetResult); // >>> 5\n\nconst grepResult = await client.arGrep(\n  'log',\n  0,\n  4,\n  [['MATCH', 'error']],\n  { NOCASE: true }\n);\nconsole.log(grepResult); // >>> [ 2, 4 ]\n\nconst grepWithValues = await client.arGrepWithValues(\n  'log',\n  0,\n  4,\n  [['GLOB', 'warn:*'], ['GLOB', 'error:*']],\n  { COMBINATOR: 'OR' }\n);\nfor (const { index, value } of grepWithValues) {\n  console.log(`${index} -> ${value}`);\n}\n// >>> 1 -> warn: disk\n// >>> 4 -> error: net",
      "section_id": "searching-elements"
    },
    {
      "id": "searching-elements-ex5",
      "language": "php",
      "code": "$res1 = $redis->armset('log', [\n            0 => 'boot: ok',\n            1 => 'warn: disk',\n            2 => 'ERROR: cpu',\n            3 => 'info: ready',\n            4 => 'error: net',\n        ]);\n        echo $res1 . PHP_EOL; // >>> 5\n\n        // Predicates are [type, value] pairs. Positional argument order is:\n        // (key, start, end, predicates, combinator, limit, withValues, noCase)\n        $res2 = $redis->argrep('log', 0, 4, [['MATCH', 'error']], null, null, false, true);\n        echo json_encode($res2) . PHP_EOL; // >>> [2,4]\n\n        $res3 = $redis->argrep(\n            'log',\n            0,\n            4,\n            [['GLOB', 'warn:*'], ['GLOB', 'error:*']],\n            'OR',\n            null,\n            true\n        );\n        foreach ($res3 as $pair) {\n            echo $pair[0] . ' -> ' . $pair[1] . PHP_EOL;\n        }\n        // >>> 1 -> warn: disk\n        // >>> 4 -> error: net",
      "section_id": "searching-elements"
    },
    {
      "id": "searching-elements-ex6",
      "language": "python",
      "code": "res30 = r.armset(\n    \"log\",\n    {\n        0: \"boot: ok\",\n        1: \"warn: disk\",\n        2: \"ERROR: cpu\",\n        3: \"info: ready\",\n        4: \"error: net\",\n    },\n)\nprint(res30)\n# >>> 5\n\nres31 = r.argrep(\n    \"log\",\n    0,\n    4,\n    [(ArrayPredicateType.MATCH, \"error\")],\n    nocase=True,\n)\nprint(res31)\n# >>> [2, 4]\n\nres32 = r.argrep(\n    \"log\",\n    0,\n    4,\n    [\n        (ArrayPredicateType.GLOB, \"warn:*\"),\n        (ArrayPredicateType.GLOB, \"error:*\"),\n    ],\n    combinator=ArrayPredicateCombinator.OR,\n    withvalues=True,\n)\nprint(res32)\n# >>> [[1, 'warn: disk'], [4, 'error: net']]",
      "section_id": "searching-elements"
    },
    {
      "id": "deleting-elements-ex0",
      "language": "plaintext",
      "code": "> ARDEL scores 1\n(integer) 1\n> ARDELRANGE scores 0 2\n(integer) 2",
      "section_id": "deleting-elements"
    },
    {
      "id": "deleting-elements-ex1",
      "language": "go",
      "code": "msetRes, err := rdb.ARMSet(ctx, \"scores\",\n\t\tredis.AREntry{Index: 0, Value: \"10\"},\n\t\tredis.AREntry{Index: 1, Value: \"20\"},\n\t\tredis.AREntry{Index: 2, Value: \"30\"},\n\t).Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(msetRes) // >>> 3\n\n\tdelRes, err := rdb.ARDel(ctx, \"scores\", 1).Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(delRes) // >>> 1\n\n\tdelRangeRes, err := rdb.ARDelRange(ctx, \"scores\", redis.ARRange{Start: 0, End: 2}).Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(delRangeRes) // >>> 2",
      "section_id": "deleting-elements"
    },
    {
      "id": "deleting-elements-ex2",
      "language": "java",
      "code": "Map<Long, String> ardelScores = new HashMap<>();\n            ardelScores.put(0L, \"10\");\n            ardelScores.put(1L, \"20\");\n            ardelScores.put(2L, \"30\");\n\n            CompletableFuture<Void> ardelExample = asyncCommands\n                    .armset(\"scores\", ardelScores)\n                    .thenCompose(res1 -> {\n                        System.out.println(res1);\n                        // >>> 3\n                        return asyncCommands.ardel(\"scores\", 1);\n                    })\n                    .thenCompose(res2 -> {\n                        System.out.println(res2);\n                        // >>> 1\n                        return asyncCommands.ardelrange(\"scores\", 0, 2);\n                    })\n                    .thenAccept(res3 -> {\n                        System.out.println(res3);\n                        // >>> 2\n                    })\n                    .toCompletableFuture();\n\n            ardelExample.join();",
      "section_id": "deleting-elements"
    },
    {
      "id": "deleting-elements-ex3",
      "language": "java",
      "code": "Map<Long, String> ardelParams = new HashMap<>();\n            ardelParams.put(0L, \"10\");\n            ardelParams.put(1L, \"20\");\n            ardelParams.put(2L, \"30\");\n\n            Mono<Long> ardel1 = reactiveCommands.armset(\"scores\", ardelParams).doOnNext(result -> {\n                System.out.println(result); // >>> 3\n            });\n\n            ardel1.block();\n\n            Mono<Long> ardel2 = reactiveCommands.ardel(\"scores\", 1).doOnNext(result -> {\n                System.out.println(result); // >>> 1\n            });\n\n            ardel2.block();\n\n            Mono<Long> ardel3 = reactiveCommands.ardelrange(\"scores\", 0, 2).doOnNext(result -> {\n                System.out.println(result); // >>> 2\n            });\n\n            ardel3.block();",
      "section_id": "deleting-elements"
    },
    {
      "id": "deleting-elements-ex4",
      "language": "javascript",
      "code": "const delSetResult = await client.arMSet('scores', { 0: '10', 1: '20', 2: '30' });\nconsole.log(delSetResult); // >>> 3\n\nconst delResult = await client.arDel('scores', 1);\nconsole.log(delResult); // >>> 1\n\nconst delRangeResult = await client.arDelRange('scores', [[0, 2]]);\nconsole.log(delRangeResult); // >>> 2",
      "section_id": "deleting-elements"
    },
    {
      "id": "deleting-elements-ex5",
      "language": "php",
      "code": "$res1 = $redis->armset('scores', [0 => '10', 1 => '20', 2 => '30']);\n        echo $res1 . PHP_EOL; // >>> 3\n\n        $res2 = $redis->ardel('scores', 1);\n        echo $res2 . PHP_EOL; // >>> 1\n\n        $res3 = $redis->ardelrange('scores', 0, 2);\n        echo $res3 . PHP_EOL; // >>> 2",
      "section_id": "deleting-elements"
    },
    {
      "id": "deleting-elements-ex6",
      "language": "python",
      "code": "res33 = r.armset(\"scores\", {0: \"10\", 1: \"20\", 2: \"30\"})\nprint(res33)\n# >>> 3\n\nres34 = r.ardel(\"scores\", 1)\nprint(res34)\n# >>> 1\n\nres35 = r.ardelrange(\"scores\", (0, 2))\nprint(res35)\n# >>> 2",
      "section_id": "deleting-elements"
    },
    {
      "id": "introspection-ex0",
      "language": "plaintext",
      "code": "> ARINFO readings\n 1) \"len\"\n 2) (integer) 3\n 3) \"count\"\n 4) (integer) 3\n 5) \"next-insert-index\"\n 6) (integer) 0\n...",
      "section_id": "introspection"
    }
  ]
}
