Skip to main content
Use LREM to remove elements equal to a given value from a list. The count decides how many occurrences are removed and in which direction: a positive count removes that many starting from the head, a negative count removes that many starting from the tail, and 0 removes every occurrence. The reply is the number of elements actually removed, and the key is deleted when the list becomes empty. Removing by value means scanning the list, so on long lists prefer a set or a sorted set when you frequently need to delete arbitrary items.

Syntax

Arguments

Response

The reply reports the result of the operation. Error replies have the same shape in RESP2 and RESP3 and are surfaced as exceptions by the SDKs below.
Client libraries often decode bulk strings, maps, sets, and numeric strings into language-native values. The table describes the Redis wire reply.

Examples

TCP examples use the TLS REDIS_URL from the Upstash console. REST examples use UPSTASH_REDIS_REST_URL and UPSTASH_REDIS_REST_TOKEN.

Related topics

LREMLPOSOverview