English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The Redis Lpush command inserts one or more values at the beginning of the list. If the key does not exist, an empty list is created and the LPUSH operation is executed. If the key exists but is not of list type, an error is returned.
Note:In Redis 2.4Before the version, the LPUSH command only accepts a single value.
The basic syntax of the redis Lpush command is as follows:
redis 127.0.0.1:6379> LPUSH KEY_NAME VALUE1.. VALUEN
=> 1.0.0
The length of the list after executing the LPUSH command.
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"