tencent cloud

Client.lIndex
最后更新时间:2025-03-10 17:15:08
Client.lIndex
最后更新时间: 2025-03-10 17:15:08
lIndex 方法用于通过索引获取列表中的元素。
lIndex(key: string, index: number): string

参数

参数
类型
描述
key
string
键名
index
number
索引

返回

类型
描述
string
成功时,返回索引对应的元素

样例

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
}

本页内容是否解决了您的问题?
您也可以 联系销售 提交工单 以寻求帮助。

文档反馈