Redis – List Lpushx Command

  • Post author:
  • Post category:Redis
  • Post comments:1 Comment

Redis LPUSHX command inserts the value at the head of the list stored at the key, only if the key already exists and holds a list.

Return Value

Integer reply, the length of the list after the push operations.

Syntax

Following is the basic syntax of Redis LPUSHX command.

redis 127.0.0.1:6379> LPUSHX KEY_NAME VALUE1.. VALUEN

Example

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

This Post Has One Comment

Leave a Reply