tencent cloud

Client.lIndex
Last updated: 2025-03-11 20:05:01
Client.lIndex
Last updated: 2025-03-11 20:05:01
The lIndex method is used to obtain elements from the list by index.
lIndex(key: string, index: number): string

Parameters

Parameter
Type
Description
key
string
Key name.
index
number
Index.

Return

Type
Description
string
On success, the elements for the index are returned.

Samples

import redis from "pts/redis";

let client = new redis.Client("redis://:<password>@<host>:6379/0");

export default function main() {
let lPushResp = client.lPush("list", "foo", "bar", "zoo");
console.log(redis lPush ${lPushResp}); // 3
let lIndexResp = client.lIndex("list", 1);
console.log(redis lIndex ${lIndexResp}); // bar
}

Was this page helpful?
You can also Contact Sales or Submit a Ticket for help.
Yes
No

Feedback