> ## Documentation Index
> Fetch the complete documentation index at: https://upstash-redis-1-18.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# ARDELRANGE

> Delete array values in one or more index ranges.

Use `ARDELRANGE` to empty every occupied slot inside one or more inclusive index ranges.

Several ranges can be given in one call and the reply is the total number of values removed across all of them, which makes it the efficient way to trim a window of an array without listing every index. As with [`ARDEL`](/redis/commands/array/ardel), deleting leaves holes instead of shifting values, and removing the last remaining value deletes the key.

Ranges that overlap are allowed; a value is counted once, when it is removed.

See the [array command overview](/redis/commands/array/overview) for the data model these commands share.

## Syntax

```redis theme={null}
ARDELRANGE <key> <start> <end> [<start> <end> ...]
```

## Arguments

| Argument        | Required | Repeatable | Description                                                                 |
| --------------- | -------- | ---------- | --------------------------------------------------------------------------- |
| `<key>`         | Yes      | No         | Array key targeted by the command.                                          |
| `<start> <end>` | Yes      | Yes        | Inclusive index range to clear. Repeat to clear several ranges in one call. |

## Important points

* The number of arguments after the key must be even; an odd count returns a wrong number of arguments error.
* Each range is applied in the order given, and the reply is the total across all of them.

## 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.

| Protocol | Reply   |
| -------- | ------- |
| RESP2    | Integer |
| RESP3    | Integer |

<Note>
  Client libraries often decode bulk strings, maps, sets, and numeric strings into language-native values. The table describes the Redis wire reply.
</Note>

## Examples

TCP examples use the TLS `REDIS_URL` from the Upstash console. REST examples use `UPSTASH_REDIS_REST_URL` and `UPSTASH_REDIS_REST_TOKEN`.

<AccordionGroup>
  <Accordion title="Redis CLI" icon="terminal">
    ```bash theme={null}
    ARDELRANGE my-array 0 99 200 299
    ```
  </Accordion>

  <Accordion title="@upstash/redis" icon="node-js" iconType="brands">
    <Note>
      This command is not supported yet in `@upstash/redis`.
    </Note>
  </Accordion>

  <Accordion title="upstash_redis" icon="python" iconType="brands">
    <Note>
      This command is not supported yet in `upstash_redis`.
    </Note>
  </Accordion>

  <Accordion title="ioredis" icon="node-js" iconType="brands">
    ```ts theme={null}
    import Redis from "ioredis";

    const redis = new Redis(process.env.REDIS_URL!);
    const result = await redis.ardelrange("my-array", 0, 99, 200, 299);
    console.log(result);
    ```
  </Accordion>

  <Accordion title="node-redis" icon="node-js" iconType="brands">
    ```ts theme={null}
    import { createClient } from "redis";

    const client = await createClient({ url: process.env.REDIS_URL })
      .on("error", console.error)
      .connect();
    const result = await client.arDelRange("my-array", [[0, 99], [200, 299]]);
    console.log(result);
    ```
  </Accordion>

  <Accordion title="redis-py" icon="python" iconType="brands">
    ```python theme={null}
    import os
    import redis

    client = redis.from_url(os.environ["REDIS_URL"])
    result = client.ardelrange("my-array", (0, 99), (200, 299))
    print(result)
    ```
  </Accordion>

  <Accordion title="go-redis" icon="golang" iconType="brands">
    ```go theme={null}
    package main

    import (
        "context"
        "fmt"
        "os"

        "github.com/redis/go-redis/v9"
    )

    func main() {
        opts, err := redis.ParseURL(os.Getenv("REDIS_URL"))
        if err != nil {
            panic(err)
        }
        client := redis.NewClient(opts)
        result, err := client.ARDelRange(context.Background(), "my-array", redis.ARRange{Start: 0, End: 99}, redis.ARRange{Start: 200, End: 299}).Result()
        if err != nil {
            panic(err)
        }
        fmt.Println(result)
    }
    ```
  </Accordion>

  <Accordion title="jedis" icon="java" iconType="brands">
    ```java theme={null}
    import java.net.URI;

    import redis.clients.jedis.Jedis;
    import redis.clients.jedis.args.LongRange;

    try (Jedis jedis = new Jedis(new URI(System.getenv("REDIS_URL")))) {
      Object result = jedis.ardelrange("my-array", LongRange.of(0, 99), LongRange.of(200, 299));
      System.out.println(result);
    }
    ```
  </Accordion>

  <Accordion title="redis-rs" icon="rust" iconType="brands">
    ```rust theme={null}
    fn main() -> redis::RedisResult<()> {
        let url = std::env::var("REDIS_URL").expect("REDIS_URL is not set");
        let client = redis::Client::open(url)?;
        let mut connection = client.get_connection()?;

        let mut command = redis::cmd("ARDELRANGE");
        command.arg("my-array");
        command.arg("0");
        command.arg("99");
        command.arg("200");
        command.arg("299");
        let result: redis::Value = command.query(&mut connection)?;
        println!("{result:?}");
        Ok(())
    }
    ```
  </Accordion>
</AccordionGroup>
