Client.lIndex

最近更新时间:2024-11-29 15:25:42

我的收藏
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
}