---
acl_categories:
- '@write'
- '@list'
- '@fast'
arguments:
- display_text: key
key_spec_index: 0
name: key
type: key
- display_text: element
multiple: true
name: element
type: string
arity: -3
categories:
- docs
- develop
- stack
- oss
- rs
- rc
- oss
- kubernetes
- clients
command_flags:
- write
- denyoom
- fast
complexity: O(1) for each element added, so O(N) to add N elements when the command
is called with multiple arguments.
description: Prepends one or more elements to a list only when the list exists.
group: list
hidden: false
history:
- - 4.0.0
- Accepts multiple `element` arguments.
key_specs:
- RW: true
begin_search:
spec:
index: 1
type: index
find_keys:
spec:
keystep: 1
lastkey: 0
limit: 0
type: range
insert: true
linkTitle: LPUSHX
railroad_diagram: /images/railroad/lpushx.svg
since: 2.2.0
summary: Prepends one or more elements to a list only when the list exists.
syntax_fmt: LPUSHX key element [element ...]
title: LPUSHX
---
Inserts specified values at the head of the list stored at `key`, only if `key`
already exists and holds a list.
In contrary to [`LPUSH`](/content/commands/lpush.md), no operation will be performed when `key` does not yet
exist.
## Required arguments
key
The name of the key that holds the list.
element [element ...]
One or more values to prepend to the list, only if it already exists.
## Examples
{{% redis-cli %}}
redis> LPUSH mylist "World"
(integer) 1
redis> LPUSHX mylist "Hello"
(integer) 2
redis> LPUSHX myotherlist "Hello"
(integer) 0
redis> LRANGE mylist 0 -1
1) "Hello"
2) "World"
redis> LRANGE myotherlist 0 -1
(empty array)
{{% /redis-cli %}}
## Redis Software and Redis Cloud compatibility
| Redis
Software | Redis
Cloud | Notes |
|:----------------------|:-----------------|:------|
| ✅ Standard
✅ Active-Active | ✅ Standard
✅ Active-Active | |
## Return information
{{< multitabs id="lpushx-return-info"
tab1="RESP2"
tab2="RESP3" >}}
[Integer reply](../../develop/reference/protocol-spec#integers): the length of the list after the push operation.
-tab-sep-
[Integer reply](../../develop/reference/protocol-spec#integers): the length of the list after the push operation.
{{< /multitabs >}}