tencent cloud

Client.lSet
Last updated: 2025-03-11 20:05:02
Client.lSet
Last updated: 2025-03-11 20:05:02
The lSet method is used to set the value of elements in the list by index.
lSet(key: string, index: number, value: string | number): string

Parameters

Parameter
Type
Description
key
string
Key name.
index
number
Index.
value
string | number
Value.

Return

Type
Description
string
On success, "OK" is 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 lSetResp = client.lSet("list", 1, "bar2");
console.log(redis lSet ${lSetResp}); // OK
let lIndexResp = client.lIndex("list", 1);
console.log(redis lIndex ${lIndexResp}); // bar2
}

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

Feedback