method

RedisClient.increx

key: KeyLike,
...options: string | number[]
): Promise<[value: number, increment: number]>;

Increment the number at a key, with optional bounds and expiration. Requires Redis 8.8 or Valkey 9.2.

@param key

The key to increment

@param options

Options of INCREX (BYINT, BYFLOAT, SATURATE, LBOUND, UBOUND, EX, PX, EXAT, PXAT, PERSIST, ENX; on Valkey also NX and XX)

@returns

Promise that resolves with the new value and the increment that was applied

await redis.increx("hits", "EX", 60, "ENX"); // [1, 1]
await redis.increx("hits", "BYINT", 5); // [6, 5]

Referenced types

type KeyLike = string | ArrayBufferView | Blob