Easy Tutorial
❮ Server Shutdown Lists Rpoplpush ❯

Redis Rpush Command

Redis Lists

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

If the list does not exist, an empty list is created and the RPUSH operation is performed.

If the list exists but is not of the list type, an error is returned.

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

Syntax

The basic syntax for 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

❮ Server Shutdown Lists Rpoplpush ❯