Redis Rpush Command

Redis Lists

The Redis Rpush command is used to insert one or more values into the tail (rightmost) of a list.

If the list does not exist, an empty list is created and the RPUSH operation is performed. When the list exists but is not a list type, an error is returned.

Note:Before Redis version 2.4, the RPUSH command only accepted a single value.

Syntax

The basic syntax of the Redis Rpush command is as follows:

redis 127.0.0.1:6379> RPUSH KEY_NAME VALUE1..VALUEN

Available Versions

>= 1.0.0

Return Value

The length of the list after the RPUSH operation.

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"

Redis Lists

Other Extensions