Latest web development tutorials

Redis Lpush command

Redis list (List)

Redis Lpush command one or more values ​​into the head of the list. If the key does not exist, an empty list will be created and executed LPUSH operation. When the key is present but not the type of list, an error is returned.

Note: In the previous version of Redis 2.4 LPUSH command only accepts a single value value.

grammar

redis Lpush basic command syntax is as follows:

redis 127.0.0.1:6379> LPUSH KEY_NAME VALUE1.. VALUEN

Available versions

> = 1.0.0

return value

After executing LPUSH command, the length of the list.

Examples

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 (List)