# XCFGSET

> Set how long a stream remembers the idempotent IDs of each producer, and how many.

URL: https://docs.hotkv.com/commands/xcfgset/

```
XCFGSET key [IDMP-DURATION seconds] [IDMP-MAXSIZE entries]
```

- Group: Stream
- HotKV Cloud: all plans
- On-Premise: no license needed

`XCFGSET` sets the two limits that govern idempotent production on an existing
stream: how many seconds a stream keeps each idempotent ID that a producer
added entries with (`IDMP-DURATION`), and how many IDs it keeps for each
producer (`IDMP-MAXSIZE`). A producer that adds an entry again with an ID the
stream still remembers adds nothing, so these limits decide how long a retry
is safe. At least one option is required.

Setting a value different from the stream's current one makes the stream
forget the IDs it holds. Setting the values it already has changes nothing, so
several publishers can each set the same limits before they publish.

## Options

| Option | Effect |
| --- | --- |
| `IDMP-DURATION seconds` | How long an idempotent ID is kept, from 1 to 86400 seconds. |
| `IDMP-MAXSIZE entries` | How many idempotent IDs are kept for each producer, from 1 to 10000. |

## Return value

Simple string `OK` in RESP2 and RESP3. `XINFO STREAM` shows the values as
`idmp-duration` and `idmp-maxsize`. Errors:

| Error | Cause |
| --- | --- |
| `ERR no such key` | The stream does not exist. |
| `WRONGTYPE Operation against a key holding the wrong kind of value` | The key holds another type. |
| `ERR IDMP-DURATION must be between 1 and 86400 seconds` | The duration is out of range. |
| `ERR IDMP-MAXSIZE must be between 1 and 10000 entries` | The size is out of range. |
| `ERR IDMP-DURATION specified multiple times`, `ERR IDMP-MAXSIZE specified multiple times` | An option is given twice. |
| `ERR value is not an integer or out of range` | A value is not a number. |
| `ERR At least one parameter must be specified` | No option given. |
| `ERR syntax error` | An unknown option, or an option with no value after it. |

## Examples

```
127.0.0.1:6379> XADD events * type signup
"1791069526348-0"
127.0.0.1:6379> XCFGSET events IDMP-DURATION 100 IDMP-MAXSIZE 50
OK
127.0.0.1:6379> XCFGSET events IDMP-DURATION 100 IDMP-MAXSIZE 50
OK
127.0.0.1:6379> XCFGSET nostream IDMP-DURATION 100
(error) ERR no such key
127.0.0.1:6379> XCFGSET events IDMP-DURATION 0
(error) ERR IDMP-DURATION must be between 1 and 86400 seconds
127.0.0.1:6379> XCFGSET events IDMP-MAXSIZE 10001
(error) ERR IDMP-MAXSIZE must be between 1 and 10000 entries
127.0.0.1:6379> XCFGSET events IDMP-DURATION 5 IDMP-DURATION 6
(error) ERR IDMP-DURATION specified multiple times
127.0.0.1:6379> XCFGSET events IDMP-DURATION abc
(error) ERR value is not an integer or out of range
127.0.0.1:6379> XCFGSET events
(error) ERR At least one parameter must be specified
127.0.0.1:6379> XCFGSET events BOGUS 1
(error) ERR syntax error
127.0.0.1:6379> XCFGSET events IDMP-DURATION
(error) ERR syntax error
127.0.0.1:6379> SET plain 1
OK
127.0.0.1:6379> XCFGSET plain IDMP-DURATION 5
(error) WRONGTYPE Operation against a key holding the wrong kind of value
```

## Compatibility

A Redis 8.6 command.

## See also

[XADD](https://docs.hotkv.com/commands/xadd/index.md), [XINFO STREAM](https://docs.hotkv.com/commands/xinfo-stream/index.md),
[XLEN](https://docs.hotkv.com/commands/xlen/index.md)