{
  "schema_version": 2,
  "id": "commands/hset",
  "title": "HSET",
  "url": "https://redis.io/docs/latest/commands/hset/",
  "summary": "Creates or modifies the value of a field in a hash.",
  "since": "2.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": "1a874c9d95073b0033c076e2536a3aa3bda49b46eb97e9799e29544e63f73e4a",
  "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 hash.\n\n</details>\n\n<details open><summary><code>field value [field value ...]</code></summary>\n\nOne or more field-value pairs to set in the hash.\n\n</details>"
    },
    {
      "id": "examples",
      "title": "Examples",
      "role": "example",
      "text": "Foundational: Set one or more field-value pairs in a hash using HSET (creates hash if needed, overwrites existing fields, returns count of new fields)\n\n**Difficulty:** Beginner\n\n**Commands:** HSET, HGET, HGETALL\n\n**Complexity:**\n- HSET: O(1)\n- HGET: O(1)\n- HGETALL: O(N)\n\n**Available in:** Redis CLI, C, C#, Go, Java, 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##### C#\n\n[code example]\n\n##### Go\n\n[code example]\n\n##### Java\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 number of fields that were added.\n\n**RESP3:**\n\n[Integer reply](../../develop/reference/protocol-spec#integers): the number of fields that were added."
    }
  ],
  "examples": [
    {
      "id": "examples-ex0",
      "language": "plaintext",
      "code": "> HSET myhash field1 \"Hello\"\n(integer) 1\n> HGET myhash field1\n\"Hello\"\n> HSET myhash field2 \"Hi\" field3 \"World\"\n(integer) 2\n> HGET myhash field2\n\"Hi\"\n> HGET myhash field3\n\"World\"\n> HGETALL myhash\n1) \"field1\"\n2) \"Hello\"\n3) \"field2\"\n4) \"Hi\"\n5) \"field3\"\n6) \"World\"",
      "section_id": "examples"
    },
    {
      "id": "examples-ex1",
      "language": "c",
      "code": "reply = redisCommand(c, \"HSET myhash field1 Hello\");\n    printf(\"%lld\\n\", reply->integer);\n    // >>> 1\n    freeReplyObject(reply);\n\n    reply = redisCommand(c, \"HGET myhash field1\");\n    printf(\"%s\\n\", reply->str);\n    // >>> Hello\n    freeReplyObject(reply);\n\n    reply = redisCommand(c, \"HSET myhash field2 Hi field3 World\");\n    printf(\"%lld\\n\", reply->integer);\n    // >>> 2\n    freeReplyObject(reply);\n\n    reply = redisCommand(c, \"HGET myhash field2\");\n    printf(\"%s\\n\", reply->str);\n    // >>> Hi\n    freeReplyObject(reply);\n\n    reply = redisCommand(c, \"HGET myhash field3\");\n    printf(\"%s\\n\", reply->str);\n    // >>> World\n    freeReplyObject(reply);\n\n    // HGETALL returns field and value alternating in a flat array.\n    reply = redisCommand(c, \"HGETALL myhash\");\n    for (size_t i = 0; i < reply->elements; i += 2) {\n        printf(\"%s=%s\\n\", reply->element[i]->str, reply->element[i + 1]->str);\n    }\n    // >>> field1=Hello\n    // >>> field2=Hi\n    // >>> field3=World\n    freeReplyObject(reply);",
      "section_id": "examples"
    },
    {
      "id": "examples-ex2",
      "language": "csharp",
      "code": "bool hsetRes1 = db.HashSet(\"myhash\", \"field1\", \"Hello\");\n        RedisValue hsetRes2 = db.HashGet(\"myhash\", \"field1\");\n        Console.WriteLine(hsetRes2);    // >>> Hello\n\n        db.HashSet(\n            \"myhash\",\n            [\n                new(\"field2\", \"Hi\"),\n                new(\"field3\", \"World\")\n            ]\n        );\n\n        RedisValue hsetRes3 = db.HashGet(\"myhash\", \"field2\");\n        Console.WriteLine(hsetRes3);    // >>> Hi\n\n        RedisValue hsetRes4 = db.HashGet(\"myhash\", \"field3\");\n        Console.WriteLine(hsetRes4);    // >>> World\n\n        HashEntry[] hsetRes5 = db.HashGetAll(\"myhash\");\n        Console.WriteLine($\"{string.Join(\", \", hsetRes5.Select(h => $\"{h.Name}: {h.Value}\"))}\");\n        // >>> field1: Hello, field2: Hi, field3: World",
      "section_id": "examples"
    },
    {
      "id": "examples-ex3",
      "language": "go",
      "code": "res1, err := rdb.HSet(ctx, \"myhash\", \"field1\", \"Hello\").Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(res1) // >>> 1\n\n\tres2, err := rdb.HGet(ctx, \"myhash\", \"field1\").Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(res2) // >>> Hello\n\n\tres3, err := rdb.HSet(ctx, \"myhash\",\n\t\t\"field2\", \"Hi\",\n\t\t\"field3\", \"World\",\n\t).Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(res3) // >>> 2\n\n\tres4, err := rdb.HGet(ctx, \"myhash\", \"field2\").Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(res4) // >>> Hi\n\n\tres5, err := rdb.HGet(ctx, \"myhash\", \"field3\").Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(res5) // >>> World\n\n\tres6, err := rdb.HGetAll(ctx, \"myhash\").Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tkeys := make([]string, 0, len(res6))\n\n\tfor key, _ := range res6 {\n\t\tkeys = append(keys, key)\n\t}\n\n\tsort.Strings(keys)\n\n\tfor _, key := range keys {\n\t\tfmt.Printf(\"Key: %v, value: %v\\n\", key, res6[key])\n\t}\n\t// >>> Key: field1, value: Hello\n\t// >>> Key: field2, value: Hi\n\t// >>> Key: field3, value: World",
      "section_id": "examples"
    },
    {
      "id": "examples-ex4",
      "language": "java",
      "code": "// `hset` returns true because `field1` is a new field.\n            boolean res4 = syncCommands.hset(\"myhash\", \"field1\", \"Hello\");\n            System.out.println(res4); // >>> true\n\n            String res5 = syncCommands.hget(\"myhash\", \"field1\");\n            System.out.println(res5); // >>> Hello\n\n            // The `Map` overload of `hset` returns the number of new fields.\n            Map<String, String> newFields = new HashMap<>();\n            newFields.put(\"field2\", \"Hi\");\n            newFields.put(\"field3\", \"World\");\n\n            Long res6 = syncCommands.hset(\"myhash\", newFields);\n            System.out.println(res6); // >>> 2\n\n            String res7 = syncCommands.hget(\"myhash\", \"field2\");\n            System.out.println(res7); // >>> Hi\n\n            String res8 = syncCommands.hget(\"myhash\", \"field3\");\n            System.out.println(res8); // >>> World\n\n            // `hgetall` returns a `Map`, whose iteration order isn't\n            // guaranteed. Wrap it in a `TreeMap` to sort the fields by name.\n            Map<String, String> res9 = syncCommands.hgetall(\"myhash\");\n            System.out.println(new TreeMap<>(res9));\n            // >>> {field1=Hello, field2=Hi, field3=World}",
      "section_id": "examples"
    },
    {
      "id": "examples-ex5",
      "language": "java",
      "code": "CompletableFuture<Void> hSetExample = asyncCommands.hset(\"myhash\", \"field1\", \"Hello\").thenCompose(res1 -> {\n                System.out.println(res1); // >>> 1\n                return asyncCommands.hget(\"myhash\", \"field1\");\n            }).thenCompose(res2 -> {\n                System.out.println(res2); // >>> Hello\n                Map<String, String> hSetExampleParams = new HashMap<>();\n                hSetExampleParams.put(\"field2\", \"Hi\");\n                hSetExampleParams.put(\"field3\", \"World\");\n                return asyncCommands.hset(\"myhash\", hSetExampleParams);\n            }).thenCompose(res3 -> {\n                System.out.println(res3); // >>> 2\n                return asyncCommands.hget(\"myhash\", \"field2\");\n            }).thenCompose(res4 -> {\n                System.out.println(res4); // >>> Hi\n                return asyncCommands.hget(\"myhash\", \"field3\");\n            }).thenCompose(res5 -> {\n                System.out.println(res5); // >>> World\n                return asyncCommands.hgetall(\"myhash\");\n            }).thenAccept(res6 -> {\n                System.out.println(res6);\n                // >>> {field1=Hello, field2=Hi, field3=World}\n            }).toCompletableFuture();",
      "section_id": "examples"
    },
    {
      "id": "examples-ex6",
      "language": "java",
      "code": "Mono<Boolean> hSetExample1 = reactiveCommands.hset(\"myhash\", \"field1\", \"Hello\").doOnNext(result -> {\n                System.out.println(result); // >>> True\n            });\n\n            hSetExample1.block();\n\n            Mono<String> hSetExample2 = reactiveCommands.hget(\"myhash\", \"field1\").doOnNext(result -> {\n                System.out.println(result); // >>> Hello\n            });\n\n            hSetExample2.block();\n\n            Map<String, String> hSetExampleParams = new HashMap<>();\n            hSetExampleParams.put(\"field2\", \"Hi\");\n            hSetExampleParams.put(\"field3\", \"World\");\n\n            Mono<Long> hSetExample3 = reactiveCommands.hset(\"myhash\", hSetExampleParams).doOnNext(result -> {\n                System.out.println(result); // >>> 2\n            });\n\n            hSetExample3.block();\n\n            Mono<String> hSetExample4 = reactiveCommands.hget(\"myhash\", \"field2\").doOnNext(result -> {\n                System.out.println(result); // >>> Hi\n            });\n\n            hSetExample4.block();\n\n            Mono<String> hSetExample5 = reactiveCommands.hget(\"myhash\", \"field3\").doOnNext(result -> {\n                System.out.println(result); // >>> World\n            });\n\n            hSetExample5.block();\n\n            Mono<Map<String, String>> hSetExample6 = reactiveCommands.hgetall(\"myhash\").collectMap(\n                    KeyValue::getKey, KeyValue::getValue\n            ).doOnNext(result -> {\n                System.out.println(result);\n                // >>> {field1=Hello, field2=Hi, field3=World}\n            });",
      "section_id": "examples"
    },
    {
      "id": "examples-ex7",
      "language": "java",
      "code": "Map<String, String> hSetExampleParams = new HashMap<>();\n        hSetExampleParams.put(\"field1\", \"Hello\");\n        long hSetResult1 = jedis.hset(\"myhash\", hSetExampleParams);\n        System.out.println(hSetResult1);    // >>> 1\n\n        String hSetResult2 = jedis.hget(\"myhash\", \"field1\");\n        System.out.println(hSetResult2);    // >>> Hello\n\n        hSetExampleParams.clear();\n        hSetExampleParams.put(\"field2\", \"Hi\");\n        hSetExampleParams.put(\"field3\", \"World\");\n        long hSetResult3 = jedis.hset(\"myhash\",hSetExampleParams);\n        System.out.println(hSetResult3);    // >>> 2\n\n        String hSetResult4 = jedis.hget(\"myhash\", \"field2\");\n        System.out.println(hSetResult4);    // >>> Hi\n\n        String hSetResult5 = jedis.hget(\"myhash\", \"field3\");\n        System.out.println(hSetResult5);    // >>> World\n\n        Map<String, String> hSetResult6 = jedis.hgetAll(\"myhash\");\n        \n        for (String key: hSetResult6.keySet()) {\n            System.out.println(\"Key: \" + key + \", Value: \" + hSetResult6.get(key));\n        }\n        // >>> Key: field3, Value: World\n        // >>> Key: field2, Value: Hi\n        // >>> Key: field1, Value: Hello",
      "section_id": "examples"
    },
    {
      "id": "examples-ex8",
      "language": "javascript",
      "code": "const res1 = await client.hSet('myhash', 'field1', 'Hello')\nconsole.log(res1) // 1\n\nconst res2 = await client.hGet('myhash', 'field1')\nconsole.log(res2) // Hello\n\nconst res3 = await client.hSet(\n  'myhash',\n  {\n    'field2': 'Hi',\n    'field3': 'World'\n  }\n)\nconsole.log(res3) // 2\n\nconst res4 = await client.hGet('myhash', 'field2')\nconsole.log(res4) // Hi\n\nconst res5 = await client.hGet('myhash', 'field3')\nconsole.log(res5) // World\n\nconst res6 = await client.hGetAll('myhash')\nconsole.log(res6)",
      "section_id": "examples"
    },
    {
      "id": "examples-ex9",
      "language": "javascript",
      "code": "const hsetRes1 = await redis.hset('myhash', 'field1', 'Hello');\nconsole.log(hsetRes1); // >>> 1\n\nconsole.log(await redis.hget('myhash', 'field1')); // >>> Hello\n\nconst hsetRes2 = await redis.hset('myhash', { field2: 'Hi', field3: 'World' });\nconsole.log(hsetRes2); // >>> 2\n\nconsole.log(await redis.hget('myhash', 'field2')); // >>> Hi\nconsole.log(await redis.hget('myhash', 'field3')); // >>> World\n\nconst hsetRes3 = await redis.hgetall('myhash');\nconsole.log(hsetRes3);\n// >>> { field1: 'Hello', field2: 'Hi', field3: 'World' }",
      "section_id": "examples"
    },
    {
      "id": "examples-ex10",
      "language": "javascript",
      "code": "const res1 = await client.hSet('myhash', 'field1', 'Hello')\nconsole.log(res1) // 1\n\nconst res2 = await client.hGet('myhash', 'field1')\nconsole.log(res2) // Hello\n\nconst res3 = await client.hSet(\n  'myhash',\n  {\n    'field2': 'Hi',\n    'field3': 'World'\n  }\n)\nconsole.log(res3) // 2\n\nconst res4 = await client.hGet('myhash', 'field2')\nconsole.log(res4) // Hi\n\nconst res5 = await client.hGet('myhash', 'field3')\nconsole.log(res5) // World\n\nconst res6 = await client.hGetAll('myhash')\nconsole.log(res6)",
      "section_id": "examples"
    },
    {
      "id": "examples-ex11",
      "language": "javascript",
      "code": "const hsetRes1 = await redis.hset('myhash', 'field1', 'Hello');\nconsole.log(hsetRes1); // >>> 1\n\nconsole.log(await redis.hget('myhash', 'field1')); // >>> Hello\n\nconst hsetRes2 = await redis.hset('myhash', { field2: 'Hi', field3: 'World' });\nconsole.log(hsetRes2); // >>> 2\n\nconsole.log(await redis.hget('myhash', 'field2')); // >>> Hi\nconsole.log(await redis.hget('myhash', 'field3')); // >>> World\n\nconst hsetRes3 = await redis.hgetall('myhash');\nconsole.log(hsetRes3);\n// >>> { field1: 'Hello', field2: 'Hi', field3: 'World' }",
      "section_id": "examples"
    },
    {
      "id": "examples-ex12",
      "language": "php",
      "code": "$hSetResult1 = $this->redis->hset('myhash', 'field1', 'Hello');\n        echo \"HSET myhash field1 Hello: \" . $hSetResult1 . \"\\n\"; // >>> 1\n\n        $hSetResult2 = $this->redis->hget('myhash', 'field1');\n        echo \"HGET myhash field1: \" . $hSetResult2 . \"\\n\"; // >>> Hello\n\n        $hSetResult3 = $this->redis->hmset('myhash', ['field2' => 'Hi', 'field3' => 'World']);\n        echo \"HMSET myhash field2 Hi field3 World: \" . ($hSetResult3 ? 'OK' : 'FAIL') . \"\\n\"; // >>> OK\n\n        $hSetResult4 = $this->redis->hget('myhash', 'field2');\n        echo \"HGET myhash field2: \" . $hSetResult4 . \"\\n\"; // >>> Hi\n\n        $hSetResult5 = $this->redis->hget('myhash', 'field3');\n        echo \"HGET myhash field3: \" . $hSetResult5 . \"\\n\"; // >>> World\n\n        $hSetResult6 = $this->redis->hgetall('myhash');\n        echo \"HGETALL myhash: \";\n        foreach ($hSetResult6 as $key => $value) {\n            echo \"Key: $key, Value: $value; \";\n        }\n        echo \"\\n\";",
      "section_id": "examples"
    },
    {
      "id": "examples-ex13",
      "language": "python",
      "code": "res1 = r.hset(\"myhash\", \"field1\", \"Hello\")\nprint(res1)\n# >>> 1\n\nres2 = r.hget(\"myhash\", \"field1\")\nprint(res2)\n# >>> Hello\n\nres3 = r.hset(\"myhash\", mapping={\"field2\": \"Hi\", \"field3\": \"World\"})\nprint(res3)\n# >>> 2\n\nres4 = r.hget(\"myhash\", \"field2\")\nprint(res4)\n# >>> Hi\n\nres5 = r.hget(\"myhash\", \"field3\")\nprint(res5)\n# >>> World\n\nres6 = r.hgetall(\"myhash\")\nprint(res6)\n# >>> { \"field1\": \"Hello\", \"field2\": \"Hi\", \"field3\": \"World\" }",
      "section_id": "examples"
    },
    {
      "id": "examples-ex14",
      "language": "ruby",
      "code": "res4 = r.hset('myhash', 'field1', 'Hello')\nputs res4 # >>> 1\n\nres5 = r.hget('myhash', 'field1')\nputs res5 # >>> Hello\n\nres6 = r.hset('myhash', { 'field2' => 'Hi', 'field3' => 'World' })\nputs res6 # >>> 2\n\nres7 = r.hget('myhash', 'field2')\nputs res7 # >>> Hi\n\nres8 = r.hget('myhash', 'field3')\nputs res8 # >>> World\n\nres9 = r.hgetall('myhash')\nputs res9.inspect\n# >>> {\"field1\"=>\"Hello\", \"field2\"=>\"Hi\", \"field3\"=>\"World\"}",
      "section_id": "examples"
    },
    {
      "id": "examples-ex15",
      "language": "rust",
      "code": "match r.hset(\"myhash\", \"field1\", \"Hello\").await {\n            Ok(res1) => {\n                let res1: i32 = res1;\n                println!(\"{res1}\");    // >>> 1\n            },\n            Err(e) => {\n                println!(\"Error setting hash field: {e}\");\n                return;\n            }\n        }\n\n        match r.hget(\"myhash\", \"field1\").await {\n            Ok(res2) => {\n                let res2: Option<String> = res2;\n                match res2 {\n                    Some(value) => {\n                        println!(\"{value}\");    // >>> Hello\n                    },\n                    None => {\n                        println!(\"None\");\n                    }\n                }\n            },\n            Err(e) => {\n                println!(\"Error getting hash field: {e}\");\n                return;\n            }\n        }\n\n        // Set multiple fields using hset_multiple\n        let hash_fields = [\n            (\"field2\", \"Hi\"),\n            (\"field3\", \"World\"),\n        ];\n\n        if let Ok(res) = r.hset_multiple(\"myhash\", &hash_fields).await {\n            let res: String = res;\n            println!(\"{res}\");    // >>> OK\n        }\n\n        match r.hget(\"myhash\", \"field2\").await {\n            Ok(res4) => {\n                let res4: Option<String> = res4;\n                match res4 {\n                    Some(value) => {\n                        println!(\"{value}\");    // >>> Hi\n                    },\n                    None => {\n                        println!(\"None\");\n                    }\n                }\n            },\n            Err(e) => {\n                println!(\"Error getting hash field: {e}\");\n                return;\n            }\n        }\n\n        match r.hget(\"myhash\", \"field3\").await {\n            Ok(res5) => {\n                let res5: Option<String> = res5;\n                match res5 {\n                    Some(value) => {\n                        println!(\"{value}\");    // >>> World\n                    },\n                    None => {\n                        println!(\"None\");\n                    }\n                }\n            },\n            Err(e) => {\n                println!(\"Error getting hash field: {e}\");\n                return;\n            }\n        }\n\n        match r.hgetall(\"myhash\").await {\n            Ok(res6) => {\n                let res6: HashMap<String, String> = res6;\n                println!(\"{res6:?}\");    // >>> {\"field1\": \"Hello\", \"field2\": \"Hi\", \"field3\": \"World\"}\n            },\n            Err(e) => {\n                println!(\"Error getting all hash fields: {e}\");\n                return;\n            }\n        }",
      "section_id": "examples"
    },
    {
      "id": "examples-ex16",
      "language": "rust",
      "code": "match r.hset(\"myhash\", \"field1\", \"Hello\") {\n            Ok(res1) => {\n                let res1: i32 = res1;\n                println!(\"{res1}\");    // >>> 1\n            },\n            Err(e) => {\n                println!(\"Error setting hash field: {e}\");\n                return;\n            }\n        }\n\n        match r.hget(\"myhash\", \"field1\") {\n            Ok(res2) => {\n                let res2: Option<String> = res2;\n                match res2 {\n                    Some(value) => {\n                        println!(\"{value}\");    // >>> Hello\n                    },\n                    None => {\n                        println!(\"None\");\n                    }\n                }\n            },\n            Err(e) => {\n                println!(\"Error getting hash field: {e}\");\n                return;\n            }\n        }\n\n        // Set multiple fields using hset_multiple\n        let hash_fields = [\n            (\"field2\", \"Hi\"),\n            (\"field3\", \"World\"),\n        ];\n\n        if let Ok(res) = r.hset_multiple(\"myhash\", &hash_fields) {\n            let res: String = res;\n            println!(\"{res}\");    // >>> OK\n        }\n\n        match r.hget(\"myhash\", \"field2\") {\n            Ok(res4) => {\n                let res4: Option<String> = res4;\n                match res4 {\n                    Some(value) => {\n                        println!(\"{value}\");    // >>> Hi\n                    },\n                    None => {\n                        println!(\"None\");\n                    }\n                }\n            },\n            Err(e) => {\n                println!(\"Error getting hash field: {e}\");\n                return;\n            }\n        }\n\n        match r.hget(\"myhash\", \"field3\") {\n            Ok(res5) => {\n                let res5: Option<String> = res5;\n                match res5 {\n                    Some(value) => {\n                        println!(\"{value}\");    // >>> World\n                    },\n                    None => {\n                        println!(\"None\");\n                    }\n                }\n            },\n            Err(e) => {\n                println!(\"Error getting hash field: {e}\");\n                return;\n            }\n        }\n\n        match r.hgetall(\"myhash\") {\n            Ok(res6) => {\n                let res6: HashMap<String, String> = res6;\n                println!(\"{res6:?}\");    // >>> {\"field1\": \"Hello\", \"field2\": \"Hi\", \"field3\": \"World\"}\n            },\n            Err(e) => {\n                println!(\"Error getting all hash fields: {e}\");\n                return;\n            }\n        }",
      "section_id": "examples"
    }
  ]
}
