Arguments
string
required
The key of the list.
unknown
required
The element to match.
Response
The index of the matching element or an array of indexes if
opts.count is
specified.Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
await redis.rpush("key", "a", "b", "c");
const index = await redis.lpos("key", "b");
console.log(index); // 1
await redis.rpush("key", "a", "b", "c", "b");
const index = await redis.lpos("key", "b", { rank: 2 });
console.log(index); // 3
await redis.rpush("key", "a", "b", "b");
const positions = await redis.lpos("key", "b", { count: 2 });
console.log(positions); // [1, 2]
Returns the index of matching elements inside a list.
opts.count is
specified.await redis.rpush("key", "a", "b", "c");
const index = await redis.lpos("key", "b");
console.log(index); // 1
await redis.rpush("key", "a", "b", "c", "b");
const index = await redis.lpos("key", "b", { rank: 2 });
console.log(index); // 3
await redis.rpush("key", "a", "b", "b");
const positions = await redis.lpos("key", "b", { count: 2 });
console.log(positions); // [1, 2]
Was this page helpful?