LPUSH

Apply for Redis Developer Course Redis Regular Inspection / Technical Support Redis Enterprise Server

Push data to the left of the list

Usage is lpush key value.
The return value is the number of values in the list.

Example

Command>lpush mylist value1
Result>1
Command>lpush mylist value2
Result>2
Command>lrange mylist 0 -1   Get the data stored in the key
Result>0) value2
1) value1
Command>lpush mylist value3 value4   You can specify multiple values
Result>4
Command>lrange mylist 0 -1
Result>0) value4
1) value3
2) value2
3) value1

View animation


Syntax

LPUSH key value [value ...]

  • Available since version 1.0.0.
  • Time complexity is O(1).

Command change history

Since version 2.4 you can specify multiple values.

SQL Insert If Redis Enterprise 7.3.0 or later, try INSERT.
Related commands LPOP, RPUSH, RPOP
Clients for Java Jedis, Lettuce, Redisson
Clients for C Hiredis

<< LISTS Introduction LPUSH LPUSHS >>

Email 답글이 올라오면 이메일로 알려드리겠습니다.