Easy Tutorial
❮ Sets Smove Sorted Sets Zscan ❯

Redis Lpushx Command

Redis Lists

Redis Lpushx inserts a value at the head of an existing list. The operation is ineffective if the list does not exist.

Syntax

The basic syntax for the redis Lpushx command is as follows:

redis 127.0.0.1:6379> LPUSHX KEY_NAME VALUE1.. VALUEN

Available Versions

= 2.2.0

Return Value

The length of the list after the LPUSHX command is executed.

Example

127.0.0.1:6379> LPUSH list1 "foo"
(integer) 1
127.0.0.1:6379> LPUSHX list1 "bar"
(integer) 2
127.0.0.1:6379> LPUSHX list2 "bar"
(integer) 0
127.0.0.1:6379> LRANGE list1 0 -1
1) "bar"
2) "foo"

Redis Lists

❮ Sets Smove Sorted Sets Zscan ❯