{
  "schema_version": 2,
  "id": "commands/rpush",
  "title": "RPUSH",
  "url": "https://redis.io/docs/latest/commands/rpush/",
  "summary": "Appends one or more elements to a list. Creates the key if it doesn't exist.",
  "since": "1.0.0",
  "tags": [
    "docs",
    "develop",
    "stack",
    "oss",
    "rs",
    "rc",
    "oss",
    "kubernetes",
    "clients"
  ],
  "last_updated": "2026-07-08T12:05:04+02:00",
  "page_type": "content",
  "content_hash": "d97f2001a4592a32d18a80f12a8c9ec4db82948a9bd4370b5483a0f1a4a00a85",
  "sections": [
    {
      "id": "required-arguments",
      "title": "Required arguments",
      "role": "content",
      "text": "<details open><summary><code>key</code></summary>\n\nThe name of the key that holds the list.\n\n</details>\n\n<details open><summary><code>element [element ...]</code></summary>\n\nOne or more values to append to the list.\n\n</details>"
    },
    {
      "id": "examples",
      "title": "Examples",
      "role": "example",
      "text": "Foundational: Add one or more elements to the tail of a list using RPUSH (creates list if needed, returns new list length)\n\n**Difficulty:** Beginner\n\n**Commands:** RPUSH, LRANGE\n\n**Complexity:**\n- RPUSH: O(1)\n- LRANGE: O(S+N)\n\n**Available in:** Redis CLI, C#, Go, Java (Asynchronous - Lettuce), Java (Reactive - Lettuce), Java (Synchronous - Jedis), JavaScript (Node.js), JavaScript (Node.js), PHP, Python, Ruby, Rust (Asynchronous), Rust (Synchronous)\n\n##### Redis CLI\n\n[code example]\n\n##### C#\n\n[code example]\n\n##### Go\n\n[code example]\n\n##### Java (Asynchronous - Lettuce)\n\n[code example]\n\n##### Java (Reactive - Lettuce)\n\n[code example]\n\n##### Java (Synchronous - Jedis)\n\n[code example]\n\n##### JavaScript (Node.js)\n\n[code example]\n\n##### JavaScript (Node.js)\n\n[code example]\n\n##### JavaScript (Node.js)\n\n[code example]\n\n##### JavaScript (Node.js)\n\n[code example]\n\n##### PHP\n\n[code example]\n\n##### Python\n\n[code example]\n\n##### Ruby\n\n[code example]\n\n##### Rust (Asynchronous)\n\n[code example]\n\n##### Rust (Synchronous)\n\n[code example]"
    },
    {
      "id": "redis-software-and-redis-cloud-compatibility",
      "title": "Redis Software and Redis Cloud compatibility",
      "role": "content",
      "text": "| Redis<br />Software | Redis<br />Cloud | <span style=\"min-width: 9em; display: table-cell\">Notes</span> |\n|:----------------------|:-----------------|:------|\n| <span title=\"Supported\">&#x2705; Standard</span><br /><span title=\"Supported\"><nobr>&#x2705; Active-Active</nobr></span> | <span title=\"Supported\">&#x2705; Standard</span><br /><span title=\"Supported\"><nobr>&#x2705; Active-Active</nobr></span> |  |"
    },
    {
      "id": "return-information",
      "title": "Return information",
      "role": "returns",
      "text": "**RESP2:**\n\n[Integer reply](../../develop/reference/protocol-spec#integers): the length of the list after the push operation.\n\n**RESP3:**\n\n[Integer reply](../../develop/reference/protocol-spec#integers): the length of the list after the push operation."
    }
  ],
  "examples": [
    {
      "id": "examples-ex0",
      "language": "plaintext",
      "code": "redis> RPUSH mylist \"hello\"\n(integer) 1\nredis> RPUSH mylist \"world\"\n(integer) 2\nredis> LRANGE mylist 0 -1\n1) \"hello\"\n2) \"world\"",
      "section_id": "examples"
    },
    {
      "id": "examples-ex1",
      "language": "csharp",
      "code": "long rPushResult1 = db.ListRightPush(\"mylist\", \"hello\");\n        Console.WriteLine(rPushResult1); // >>> 1\n\n        long rPushResult2 = db.ListRightPush(\"mylist\", \"world\");\n        Console.WriteLine(rPushResult2); // >>> 2\n\n        RedisValue[] rPushResult3 = db.ListRange(\"mylist\", 0, -1);\n        Console.WriteLine($\"[{string.Join(\", \", rPushResult3)}]\");\n        // >>> [hello, world]",
      "section_id": "examples"
    },
    {
      "id": "examples-ex2",
      "language": "go",
      "code": "rPushResult1, err := rdb.RPush(ctx, \"mylist\", \"Hello\").Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(rPushResult1) // >>> 1\n\n\trPushResult2, err := rdb.RPush(ctx, \"mylist\", \"World\").Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(rPushResult2) // >>> 2\n\n\tlRangeResult, err := rdb.LRange(ctx, \"mylist\", 0, -1).Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(lRangeResult) // >>> [Hello World]",
      "section_id": "examples"
    },
    {
      "id": "examples-ex3",
      "language": "java",
      "code": "CompletableFuture<Void> rpush = asyncCommands.rpush(\"mylist\", \"hello\").thenCompose(res14 -> {\n                System.out.println(res14); // >>> 1\n\n                return asyncCommands.rpush(\"mylist\", \"world\");\n            }).thenCompose(res15 -> {\n                System.out.println(res15); // >>> 2\n\n                return asyncCommands.lrange(\"mylist\", 0, -1);\n            })\n                    .thenAccept(res16 -> System.out.println(res16)) // >>> [hello, world]\n                    .toCompletableFuture();",
      "section_id": "examples"
    },
    {
      "id": "examples-ex4",
      "language": "java",
      "code": "Mono<Void> rpush = reactiveCommands.rpush(\"mylist\", \"hello\").doOnNext(res14 -> {\n                System.out.println(res14); // >>> 1\n            }).flatMap(res14 -> reactiveCommands.rpush(\"mylist\", \"world\")).doOnNext(res15 -> {\n                System.out.println(res15); // >>> 2\n            }).flatMap(res15 -> reactiveCommands.lrange(\"mylist\", 0, -1).collectList()).doOnNext(res16 -> {\n                System.out.println(res16); // >>> [hello, world]\n            }).then();",
      "section_id": "examples"
    },
    {
      "id": "examples-ex5",
      "language": "java",
      "code": "long rPushResult1 = jedis.rpush(\"mylist\", \"hello\");\n        System.out.println(rPushResult1); // >>> 1\n\n        long rPushResult2 = jedis.rpush(\"mylist\", \"world\");\n        System.out.println(rPushResult2); // >>> 2\n\n        List<String> rPushResult3 = jedis.lrange(\"mylist\", 0, -1);\n        System.out.println(rPushResult3); // >>> [hello, world]",
      "section_id": "examples"
    },
    {
      "id": "examples-ex6",
      "language": "javascript",
      "code": "const res14 = await client.rPush('mylist', 'hello');\nconsole.log(res14); // 1\n\nconst res15 = await client.rPush('mylist', 'world');\nconsole.log(res15); // 2\n\nconst res16 = await client.lRange('mylist', 0, -1);\nconsole.log(res16); // [ 'hello', 'world' ]",
      "section_id": "examples"
    },
    {
      "id": "examples-ex7",
      "language": "javascript",
      "code": "const res14 = await redis.rpush('mylist', 'hello');\nconsole.log(res14); // >>> 1\n\nconst res15 = await redis.rpush('mylist', 'world');\nconsole.log(res15); // >>> 2\n\nconst res16 = await redis.lrange('mylist', 0, -1);\nconsole.log(res16); // >>> ['hello', 'world']",
      "section_id": "examples"
    },
    {
      "id": "examples-ex8",
      "language": "javascript",
      "code": "const res14 = await client.rPush('mylist', 'hello');\nconsole.log(res14); // 1\n\nconst res15 = await client.rPush('mylist', 'world');\nconsole.log(res15); // 2\n\nconst res16 = await client.lRange('mylist', 0, -1);\nconsole.log(res16); // [ 'hello', 'world' ]",
      "section_id": "examples"
    },
    {
      "id": "examples-ex9",
      "language": "javascript",
      "code": "const res14 = await redis.rpush('mylist', 'hello');\nconsole.log(res14); // >>> 1\n\nconst res15 = await redis.rpush('mylist', 'world');\nconsole.log(res15); // >>> 2\n\nconst res16 = await redis.lrange('mylist', 0, -1);\nconsole.log(res16); // >>> ['hello', 'world']",
      "section_id": "examples"
    },
    {
      "id": "examples-ex10",
      "language": "php",
      "code": "$res14 = $r->rpush('mylist', 'hello');\n        echo $res14 . PHP_EOL;\n        // >>> 1\n\n        $res15 = $r->rpush('mylist', 'world');\n        echo $res15 . PHP_EOL;\n        // >>> 2\n\n        $res16 = $r->lrange('mylist', 0, -1);\n        echo json_encode($res16) . PHP_EOL;\n        // >>> [\"hello\",\"world\"]",
      "section_id": "examples"
    },
    {
      "id": "examples-ex11",
      "language": "python",
      "code": "res14 = r.rpush(\"mylist\", \"hello\")\nprint(res14) # >>> 1\n\nres15 = r.rpush(\"mylist\", \"world\")\nprint(res15) # >>> 2\n\nres16 = r.lrange(\"mylist\", 0, -1)\nprint(res16)  # >>> [ \"hello\", \"world\" ]",
      "section_id": "examples"
    },
    {
      "id": "examples-ex12",
      "language": "ruby",
      "code": "res14 = r.rpush('mylist', 'hello')\nputs res14 # >>> 1\n\nres15 = r.rpush('mylist', 'world')\nputs res15 # >>> 2\n\nres16 = r.lrange('mylist', 0, -1)\nputs res16.inspect # >>> [\"hello\", \"world\"]",
      "section_id": "examples"
    },
    {
      "id": "examples-ex13",
      "language": "rust",
      "code": "if let Ok(res14) = r.rpush(\"mylist\", \"hello\").await {\n            let res14: i32 = res14;\n            println!(\"{res14}\"); // >>> 1\n        }\n\n        if let Ok(res15) = r.rpush(\"mylist\", \"world\").await {\n            let res15: i32 = res15;\n            println!(\"{res15}\"); // >>> 2\n        }\n\n        if let Ok(res16) = r.lrange(\"mylist\", 0, -1).await {\n            let res16: Vec<String> = res16;\n            println!(\"{res16:?}\"); // >>> [\"hello\", \"world\"]\n        }",
      "section_id": "examples"
    },
    {
      "id": "examples-ex14",
      "language": "rust",
      "code": "if let Ok(res14) = r.rpush(\"mylist\", \"hello\") {\n            let res14: i32 = res14;\n            println!(\"{res14}\"); // >>> 1\n        }\n\n        if let Ok(res15) = r.rpush(\"mylist\", \"world\") {\n            let res15: i32 = res15;\n            println!(\"{res15}\"); // >>> 2\n        }\n\n        if let Ok(res16) = r.lrange(\"mylist\", 0, -1) {\n            let res16: Vec<String> = res16;\n            println!(\"{res16:?}\"); // >>> [\"hello\", \"world\"]\n        }",
      "section_id": "examples"
    }
  ]
}
