tencent cloud

腾讯云可观测平台

Client.lIndex

PDF
聚焦模式
字号
最后更新时间: 2025-03-11 20:05:01
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
}


帮助和支持

本页内容是否解决了您的问题?

填写满意度调查问卷,共创更好文档体验。

文档反馈