Redis Lpush Command
The Redis Lpush command inserts one or more values at the head of the list. If key does not exist, an empty list is created and the LPUSH operation is performed. When key exists but is not of list type, returns an error.
**Note:** Before Redis version 2.4, the LPUSH command only accepted a single value.
Syntax
The basic syntax of the redis Lpush command is as follows:
redis 127.0.0.1:6379> LPUSH KEY_NAME VALUE1.. VALUEN
Available Version
= 1.0.0
Return Value
The length of the list after the LPUSH command is executed.
Example
127.0.0.1:6379> LPUSH list1 "foo"
(integer) 1
127.0.0.1:6379> LPUSH list1 "bar"
(integer) 2
127.0.0.1:6379> LRANGE list1 0 -1
1) "bar"
2) "foo"
Redis List