Redis – List Rpush Command

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

Redis RPUSH command inserts all the specified values at the tail of the list stored at the key. If the key does not exist, it is created as an empty list before performing the push operation. When the key holds a value that is not a list, an error is returned.

Return Value

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

Syntax

Following is the basic syntax of Redis RPUSH command.

redis 127.0.0.1:6379> RPUSH KEY_NAME VALUE1..VALUEN 

Example

redis 127.0.0.1:6379> RPUSH mylist "hello" 
(integer) 1 
redis 127.0.0.1:6379> RPUSH mylist "foo" 
(integer) 2 
redis 127.0.0.1:6379> RPUSH mylist "bar" 
(integer) 3 
redis 127.0.0.1:6379> LRANGE mylist 0 -1 
1) "hello"
2) "foo" 
3) "bar"

This Post Has One Comment

Leave a Reply