tencent cloud

All product documents
Tencent Cloud Observability Platform
Client.lRem
Last updated: 2025-03-11 20:05:02
Client.lRem
Last updated: 2025-03-11 20:05:02
The lRem method is used to remove elements from the list.
lRem(key: string, count: number, value: string | number): number

Parameters

Parameter
Type
Description
key
string
Key name.
count
number
The number of elements removed. Positive values indicate starting from the head of the list, negative values indicate starting from the tail of the list, and 0 indicates removing all.
value
string | number
The value of the removed element.

Return

Type
Description
number
On success, the number of removed elements 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", "foo", "bar", "zoo");
console.log(redis lPush ${lPushResp}); // 6
let lRemResp1 = client.lRem("list", 1, "bar");
console.log(redis lRem ${lRemResp1}); // 1
let lRemResp2 = client.lRem("list", -1, "foo");
console.log(redis lRem ${lRemResp2}); // 1
let lRangeResp = client.lRange("list", 0, 4);
console.log(redis lRange ${lRangeResp}); // zoo,foo,zoo,bar
}

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

Feedback

Contact Us

Contact our sales team or business advisors to help your business.

Technical Support

Open a ticket if you're looking for further assistance. Our Ticket is 7x24 avaliable.

7x24 Phone Support
Hong Kong, China
+852 800 906 020 (Toll Free)
United States
+1 844 606 0804 (Toll Free)
United Kingdom
+44 808 196 4551 (Toll Free)
Canada
+1 888 605 7930 (Toll Free)
Australia
+61 1300 986 386 (Toll Free)
EdgeOne hotline
+852 300 80699
More local hotlines coming soon