Only the Chinese version of this page is provided currently. The English version will be provided soon.

Client.lIndex

Last updated: 2024-11-29 11:04:52

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
}