# LPUSH

> Insert one or more elements at the head of a list.

URL: https://docs.hotkv.com/commands/lpush/

```
LPUSH key element [element ...]
```

- Group: List
- Complexity: O(1) for each element added
- HotKV Cloud: all plans
- On-Premise: no license needed

`LPUSH` inserts each `element` at the head (left end) of the list stored at
`key`, creating the list if the key does not exist. Elements are inserted one
after another from left to right, so `LPUSH key a b c` leaves `c` first.

Pushing to a list wakes clients blocked on it with
[BLPOP](https://docs.hotkv.com/commands/blpop/index.md) and related commands.

## Return value

| Case | RESP2 | RESP3 |
| --- | --- | --- |
| Success | Integer: the length of the list after the push | Same |

`LPUSH` replies with a `WRONGTYPE` error if `key` holds a value that is not a
list.

## Examples

```
127.0.0.1:6379> LPUSH queue a b c
(integer) 3
127.0.0.1:6379> LRANGE queue 0 -1
1) "c"
2) "b"
3) "a"
```

## Compatibility

Same as Redis 7.4 and Valkey 8.

## See also

[RPUSH](https://docs.hotkv.com/commands/rpush/index.md), [LPUSHX](https://docs.hotkv.com/commands/lpushx/index.md), [LPOP](https://docs.hotkv.com/commands/lpop/index.md),
[LRANGE](https://docs.hotkv.com/commands/lrange/index.md), [BLPOP](https://docs.hotkv.com/commands/blpop/index.md)