List
LPUSHX
Push an element at the head of the list only if the list exists.
await redis.lpush("key", "a", "b", "c");
const length = await redis.lpushx("key", "d");
console.log(length); // 4
Arguments
key
string
requiredThe key of the list.
elements
...TValue[]
requiredOne or more elements to push at the head of the list.
Response
The length of the list after the push operation.
0
if the list did not exist and thus no element was pushed.
await redis.lpush("key", "a", "b", "c");
const length = await redis.lpushx("key", "d");
console.log(length); // 4