{
  "schema_version": 2,
  "id": "commands/llen",
  "title": "LLEN",
  "url": "https://redis.io/docs/latest/commands/llen/",
  "summary": "Returns the length of a list.",
  "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": "8dfc5414cffc25f49acfc64f069d792786476e250231b3de58aa18249ceab354",
  "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>"
    },
    {
      "id": "examples",
      "title": "Examples",
      "role": "example",
      "text": "Foundational: Get the length of a list using LLEN (returns 0 if key doesn't exist, useful for checking list size)\n\n**Difficulty:** Beginner\n\n**Commands:** LPUSH, LLEN\n\n**Complexity:**\n- LPUSH: O(1)\n- LLEN: O(1)\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.\n\n**RESP3:**\n\n[Integer reply](../../develop/reference/protocol-spec#integers): the length of the list."
    }
  ],
  "examples": [
    {
      "id": "examples-ex0",
      "language": "plaintext",
      "code": "redis> LPUSH mylist \"World\"\n(integer) 1\nredis> LPUSH mylist \"Hello\"\n(integer) 2\nredis> LLEN mylist\n(integer) 2",
      "section_id": "examples"
    },
    {
      "id": "examples-ex1",
      "language": "csharp",
      "code": "long lLenResult1 = db.ListLeftPush(\"mylist\", \"World\");\n        Console.WriteLine(lLenResult1); // >>> 1\n\n        long lLenResult2 = db.ListLeftPush(\"mylist\", \"Hello\");\n        Console.WriteLine(lLenResult2); // >>> 2\n\n        long lLenResult3 = db.ListLength(\"mylist\");\n        Console.WriteLine(lLenResult3); // >>> 2",
      "section_id": "examples"
    },
    {
      "id": "examples-ex2",
      "language": "go",
      "code": "lPushResult1, err := rdb.LPush(ctx, \"mylist\", \"World\").Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(lPushResult1) // >>> 1\n\n\tlPushResult2, err := rdb.LPush(ctx, \"mylist\", \"Hello\").Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(lPushResult2) // >>> 2\n\n\tlLenResult, err := rdb.LLen(ctx, \"mylist\").Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(lLenResult) // >>> 2",
      "section_id": "examples"
    },
    {
      "id": "examples-ex3",
      "language": "java",
      "code": "CompletableFuture<Void> llen = asyncCommands.lpush(\"mylist\", \"World\").thenCompose(res11 -> {\n                System.out.println(res11); // >>> 1\n\n                return asyncCommands.lpush(\"mylist\", \"Hello\");\n            }).thenCompose(res12 -> {\n                System.out.println(res12); // >>> 2\n\n                return asyncCommands.llen(\"mylist\");\n            })\n                    .thenAccept(res13 -> System.out.println(res13)) // >>> 2\n                    .toCompletableFuture();",
      "section_id": "examples"
    },
    {
      "id": "examples-ex4",
      "language": "java",
      "code": "Mono<Void> llen = reactiveCommands.lpush(\"mylist\", \"World\").doOnNext(res11 -> {\n                System.out.println(res11); // >>> 1\n            }).flatMap(res11 -> reactiveCommands.lpush(\"mylist\", \"Hello\")).doOnNext(res12 -> {\n                System.out.println(res12); // >>> 2\n            }).flatMap(res12 -> reactiveCommands.llen(\"mylist\")).doOnNext(res13 -> {\n                System.out.println(res13); // >>> 2\n            }).then();",
      "section_id": "examples"
    },
    {
      "id": "examples-ex5",
      "language": "java",
      "code": "long lLenResult1 = jedis.lpush(\"mylist\", \"World\");\n        System.out.println(lLenResult1); // >>> 1\n\n        long lLenResult2 = jedis.lpush(\"mylist\", \"Hello\");\n        System.out.println(lLenResult2); // >>> 2\n\n        long lLenResult3 = jedis.llen(\"mylist\");\n        System.out.println(lLenResult3); // >>> 2",
      "section_id": "examples"
    },
    {
      "id": "examples-ex6",
      "language": "javascript",
      "code": "const res11 = await client.lPush('mylist', 'World');\nconsole.log(res11); // 1\n\nconst res12 = await client.lPush('mylist', 'Hello');\nconsole.log(res12); // 2\n\nconst res13 = await client.lLen('mylist');\nconsole.log(res13); // 2",
      "section_id": "examples"
    },
    {
      "id": "examples-ex7",
      "language": "javascript",
      "code": "const res11 = await redis.lpush('mylist', 'World');\nconsole.log(res11); // >>> 1\n\nconst res12 = await redis.lpush('mylist', 'Hello');\nconsole.log(res12); // >>> 2\n\nconst res13 = await redis.llen('mylist');\nconsole.log(res13); // >>> 2",
      "section_id": "examples"
    },
    {
      "id": "examples-ex8",
      "language": "javascript",
      "code": "const res11 = await client.lPush('mylist', 'World');\nconsole.log(res11); // 1\n\nconst res12 = await client.lPush('mylist', 'Hello');\nconsole.log(res12); // 2\n\nconst res13 = await client.lLen('mylist');\nconsole.log(res13); // 2",
      "section_id": "examples"
    },
    {
      "id": "examples-ex9",
      "language": "javascript",
      "code": "const res11 = await redis.lpush('mylist', 'World');\nconsole.log(res11); // >>> 1\n\nconst res12 = await redis.lpush('mylist', 'Hello');\nconsole.log(res12); // >>> 2\n\nconst res13 = await redis.llen('mylist');\nconsole.log(res13); // >>> 2",
      "section_id": "examples"
    },
    {
      "id": "examples-ex10",
      "language": "php",
      "code": "$res11 = $r->lpush('mylist', 'World');\n        echo $res11 . PHP_EOL;\n        // >>> 1\n\n        $res12 = $r->lpush('mylist', 'Hello');\n        echo $res12 . PHP_EOL;\n        // >>> 2\n\n        $res13 = $r->llen('mylist');\n        echo $res13 . PHP_EOL;\n        // >>> 2",
      "section_id": "examples"
    },
    {
      "id": "examples-ex11",
      "language": "python",
      "code": "res11 = r.lpush(\"mylist\", \"World\")\nprint(res11) # >>> 1\n\nres12 = r.lpush(\"mylist\", \"Hello\")\nprint(res12) # >>> 2\n\nres13 = r.llen(\"mylist\")\nprint(res13)  # >>> 2",
      "section_id": "examples"
    },
    {
      "id": "examples-ex12",
      "language": "ruby",
      "code": "res11 = r.lpush('mylist', 'World')\nputs res11 # >>> 1\n\nres12 = r.lpush('mylist', 'Hello')\nputs res12 # >>> 2\n\nres13 = r.llen('mylist')\nputs res13 # >>> 2",
      "section_id": "examples"
    },
    {
      "id": "examples-ex13",
      "language": "rust",
      "code": "if let Ok(res11) = r.lpush(\"mylist\", \"World\").await {\n            let res11: i32 = res11;\n            println!(\"{res11}\"); // >>> 1\n        }\n\n        if let Ok(res12) = r.lpush(\"mylist\", \"Hello\").await {\n            let res12: i32 = res12;\n            println!(\"{res12}\"); // >>> 2\n        }\n\n        if let Ok(res13) = r.llen(\"mylist\").await {\n            let res13: i32 = res13;\n            println!(\"{res13}\"); // >>> 2\n        }",
      "section_id": "examples"
    },
    {
      "id": "examples-ex14",
      "language": "rust",
      "code": "if let Ok(res11) = r.lpush(\"mylist\", \"World\") {\n            let res11: i32 = res11;\n            println!(\"{res11}\"); // >>> 1\n        }\n\n        if let Ok(res12) = r.lpush(\"mylist\", \"Hello\") {\n            let res12: i32 = res12;\n            println!(\"{res12}\"); // >>> 2\n        }\n\n        if let Ok(res13) = r.llen(\"mylist\") {\n            let res13: i32 = res13;\n            println!(\"{res13}\"); // >>> 2\n        }",
      "section_id": "examples"
    }
  ]
}
