# ARSEEK

> Move the array append cursor.

Use `ARSEEK` to set the index that the next [`ARINSERT`](/redis/commands/array/arinsert) will write to.

Appending normally continues from wherever the last append left off. `ARSEEK` overrides that, which is how a producer restarts a run at a known offset, or rewinds the cursor so that a region is rewritten rather than extended. Seeking to `0` returns the array to its never-appended state, so the next append goes to index `0`.

Moving the cursor does not read, write, or delete any value, so seeking backward over occupied slots leaves them in place until an append overwrites them. The reply is `1` when the cursor was moved and `0` when the key does not exist.

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

## Syntax

```redis
ARSEEK <key> <index>
```

## Arguments

| Argument | Required | Repeatable | Description |
| --- | --- | --- | --- |
| `<key>` | Yes | No | Array key targeted by the command. |
| `<index>` | Yes | No | Index that the next append should write to. |

## Important points

- `ARSEEK` does not create the key. Seeking on a key that does not exist replies `0` and changes nothing.
- The values already stored are left untouched; only the cursor moves.

## 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
ARSEEK my-array 0
```

</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
import Redis from "ioredis";

const redis = new Redis(process.env.REDIS_URL!);
const result = await redis.arseek("my-array", 0);
console.log(result);
```

</Accordion>

<Accordion title="node-redis" icon="node-js" iconType="brands">

```ts
import { createClient } from "redis";

const client = await createClient({ url: process.env.REDIS_URL })
  .on("error", console.error)
  .connect();
const result = await client.arSeek("my-array", 0);
console.log(result);
```

</Accordion>

<Accordion title="redis-py" icon="python" iconType="brands">

```python
import os
import redis

client = redis.from_url(os.environ["REDIS_URL"])
result = client.arseek("my-array", 0)
print(result)
```

</Accordion>

<Accordion title="go-redis" icon="golang" iconType="brands">

```go
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.ARSeek(context.Background(), "my-array", 0).Result()
    if err != nil {
        panic(err)
    }
    fmt.Println(result)
}
```

</Accordion>

<Accordion title="jedis" icon="java" iconType="brands">

```java
import java.net.URI;

import redis.clients.jedis.Jedis;

try (Jedis jedis = new Jedis(new URI(System.getenv("REDIS_URL")))) {
  Object result = jedis.arseek("my-array", 0);
  System.out.println(result);
}
```

</Accordion>

<Accordion title="redis-rs" icon="rust" iconType="brands">

```rust
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("ARSEEK");
    command.arg("my-array");
    command.arg("0");
    let result: redis::Value = command.query(&mut connection)?;
    println!("{result:?}");
    Ok(())
}
```

</Accordion>

</AccordionGroup>
