{
  "schema_version": 2,
  "id": "develop/get-started/data-store",
  "title": "Redis as an in-memory data structure store quick start guide",
  "url": "https://redis.io/docs/latest/develop/get-started/data-store/",
  "summary": "Understand how to use basic Redis data types",
  "aliases": [
    "/get-started/data-store/"
  ],
  "tags": [
    "docs",
    "develop",
    "stack",
    "oss",
    "rs",
    "rc",
    "oss",
    "kubernetes",
    "clients"
  ],
  "last_updated": "2026-09-29T16:29:37+01:00",
  "page_type": "content",
  "content_hash": "bd63c4df0a837ab16309c88a333a140ebe489498c1110734d6b6e74eae7eb995",
  "sections": [
    {
      "id": "setup",
      "title": "Setup",
      "role": "setup",
      "text": "The easiest way to get started with Redis is to use Redis Cloud:\n\n1. Create a [free account](https://redis.com/try-free?utm_source=redisio&utm_medium=referral&utm_campaign=2023-09-try_free&utm_content=cu-redis_cloud_users).\n\n    ![](https://redis.io/docs/latest/images/dev/free-cloud-db.png)\n\n2. Follow the instructions to create a free database.\n\nYou can alternatively follow the [installation guides](https://redis.io/docs/latest/operate/oss_and_stack/install/install-stack) to install Redis on your local machine."
    },
    {
      "id": "connect",
      "title": "Connect",
      "role": "content",
      "text": "The first step is to connect to Redis. You can find further details about the connection options in this documentation site's [Tools section](https://redis.io/docs/latest/develop/tools). The following example shows how to connect to a Redis server that runs on localhost (`-h 127.0.0.1`) and listens on the default port (`-p 6379`): \n\nFoundational: Connect to a Redis server\n\n**Difficulty:** Beginner\n\n**Commands:** REDIS-CLI\n\n**Available in:** Redis CLI, C#, Go, Java (Synchronous - Jedis), JavaScript (Node.js), Python\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 (Synchronous - Jedis)\n\n[code example]\n\n##### JavaScript (Node.js)\n\n[code example]\n\n##### Python\n\n[code example]\n\n\n<br/>\n\n&nbsp;\n\n> [!TIP]\n> You can copy and paste the connection details from the Redis Cloud database configuration page. Here is an example connection string of a Cloud database that is hosted in the AWS region `us-east-1` and listens on port 16379: `redis-16379.c283.us-east-1-4.ec2.cloud.redislabs.com:16379`. The connection string has the format `host:port`. You must also copy and paste the username and password of your Cloud database and then either pass the credentials to your client or use the [AUTH command](https://redis.io/docs/latest/commands/auth) after the connection is established."
    },
    {
      "id": "store-and-retrieve-data",
      "title": "Store and retrieve data",
      "role": "content",
      "text": "Redis stands for Remote Dictionary Server. You can use the same data types as in your local programming environment but on the server side within Redis.\n\nSimilar to byte arrays, Redis strings store sequences of bytes, including text, serialized objects, counter values, and binary arrays. The following example shows you how to set and get a string value:\n\nFoundational: Set and retrieve string values using SET and GET commands\n\n**Difficulty:** Beginner\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]\n\n\n\nHashes are the equivalent of dictionaries (dicts or hash maps). Among other things, you can use hashes to represent plain objects and to store groupings of counters. The following example explains how to set and access field values of an object:\n\nFoundational: Store and retrieve hash data structures using HSET to set multiple fields, HGET to retrieve individual fields, and HGETALL to retrieve all fields at once\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#, Go, Java (Asynchronous - Lettuce), Java (Reactive - Lettuce), Java (Synchronous - Jedis), 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##### 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]\n\n\n\nYou can get a complete overview of available data types in this documentation site's [data types section](https://redis.io/docs/latest/develop/data-types). Each data type has commands allowing you to manipulate or retrieve data. The [commands reference](/commands/) provides a sophisticated explanation."
    },
    {
      "id": "scan-the-keyspace",
      "title": "Scan the keyspace",
      "role": "content",
      "text": "Each item within Redis has a unique key. All items live within the Redis [keyspace](https://redis.io/docs/latest/develop/using-commands/keyspace). You can scan the Redis keyspace via the [SCAN command](https://redis.io/docs/latest/commands/scan). Here is an example that scans for the first 100 keys that have the prefix `bike:`:\n\n[code example]\n\n[SCAN](https://redis.io/docs/latest/commands/scan) returns a cursor position, allowing you to scan iteratively for the next batch of keys until you reach the cursor value 0."
    },
    {
      "id": "next-steps",
      "title": "Next steps",
      "role": "content",
      "text": "You can address more use cases with Redis by reading these additional quick start guides:\n\n* [Redis as a document database](https://redis.io/docs/latest/develop/get-started/search-tutorial)\n* [Redis as a vector database](https://redis.io/docs/latest/develop/get-started/search-tutorial/vector-search)"
    },
    {
      "id": "continue-learning-with-redis-university",
      "title": "Continue learning with Redis University",
      "role": "content",
      "text": ""
    }
  ],
  "examples": [
    {
      "id": "connect-ex0",
      "language": "plaintext",
      "code": "> redis-cli -h 127.0.0.1 -p 6379",
      "section_id": "connect"
    },
    {
      "id": "connect-ex1",
      "language": "csharp",
      "code": "var muxer = ConnectionMultiplexer.Connect(\"localhost:6379\");\n        var db = muxer.GetDatabase();\n        var ft = db.FT();\n        var json = db.JSON();",
      "section_id": "connect"
    },
    {
      "id": "connect-ex2",
      "language": "go",
      "code": "ctx := context.Background()\n\n\trdb := redis.NewClient(&redis.Options{\n\t\tAddr:     \"localhost:6379\",\n\t\tPassword: \"\", // no password docs\n\t\tDB:       0,  // use default DB\n\t\tProtocol: 2,\n\t})",
      "section_id": "connect"
    },
    {
      "id": "connect-ex3",
      "language": "java",
      "code": "RedisClient jedis = RedisClient.create(\"localhost\", 6379);",
      "section_id": "connect"
    },
    {
      "id": "connect-ex4",
      "language": "javascript",
      "code": "const client = createClient();\nclient.on('error', err => console.log('Redis Client Error', err));\n\nawait client.connect();",
      "section_id": "connect"
    },
    {
      "id": "connect-ex5",
      "language": "python",
      "code": "r = redis.Redis(host=\"localhost\", port=6379, db=0, decode_responses=True)",
      "section_id": "connect"
    },
    {
      "id": "store-and-retrieve-data-ex0",
      "language": "plaintext",
      "code": "> SET bike:1 \"Process 134\"\n> GET bike:1",
      "section_id": "store-and-retrieve-data"
    },
    {
      "id": "store-and-retrieve-data-ex1",
      "language": "csharp",
      "code": "using NRedisStack.Tests;\nusing StackExchange.Redis;\n\npublic class SetGetExample\n{\n    public void Run()\n    {\n        var muxer = ConnectionMultiplexer.Connect(\"localhost:6379\");\n        var db = muxer.GetDatabase();\n\n        bool status = db.StringSet(\"bike:1\", \"Process 134\");\n\n        if (status)\n            Console.WriteLine(\"Successfully added a bike.\");\n\n        var value = db.StringGet(\"bike:1\");\n\n        if (value.HasValue)\n            Console.WriteLine(\"The name of the bike is: \" + value + \".\");\n\n    }\n}",
      "section_id": "store-and-retrieve-data"
    },
    {
      "id": "store-and-retrieve-data-ex2",
      "language": "go",
      "code": "package example_commands_test\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/redis/go-redis/v9\"\n)\n\nfunc ExampleClient_Set_and_get() {\n\tctx := context.Background()\n\n\trdb := redis.NewClient(&redis.Options{\n\t\tAddr:     \"localhost:6379\",\n\t\tPassword: \"\", // no password docs\n\t\tDB:       0,  // use default DB\n\t})\n\n\n\n\terr := rdb.Set(ctx, \"bike:1\", \"Process 134\", 0).Err()\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(\"OK\")\n\n\tvalue, err := rdb.Get(ctx, \"bike:1\").Result()\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tfmt.Printf(\"The name of the bike is %s\", value)\n\n}",
      "section_id": "store-and-retrieve-data"
    },
    {
      "id": "store-and-retrieve-data-ex3",
      "language": "java",
      "code": "package io.redis.examples.async;\n\nimport io.lettuce.core.RedisClient;\nimport io.lettuce.core.api.async.RedisAsyncCommands;\nimport io.lettuce.core.api.StatefulRedisConnection;\n\nimport java.util.concurrent.CompletableFuture;\n\npublic class SetGetExample {\n\n    public void run() {\n        RedisClient redisClient = RedisClient.create(\"redis://localhost:6379\");\n\n        try (StatefulRedisConnection<String, String> connection = redisClient.connect()) {\n            RedisAsyncCommands<String, String> asyncCommands = connection.async();\n\n\n            CompletableFuture<Void> setGetExample = asyncCommands.set(\"bike:1\", \"Process 134\")\n                    .thenCompose(res1 -> {\n                        System.out.println(res1); // >>> OK\n                        return asyncCommands.get(\"bike:1\");\n                    }).thenAccept(res2 -> {\n                        System.out.println(res2); // >>> Process 134\n                    }).toCompletableFuture();\n\n            setGetExample.join();\n        } finally {\n            redisClient.shutdown();\n        }\n    }\n}",
      "section_id": "store-and-retrieve-data"
    },
    {
      "id": "store-and-retrieve-data-ex4",
      "language": "java",
      "code": "package io.redis.examples.reactive;\n\nimport io.lettuce.core.RedisClient;\nimport io.lettuce.core.api.reactive.RedisReactiveCommands;\nimport io.lettuce.core.api.StatefulRedisConnection;\n\nimport reactor.core.publisher.Mono;\n\npublic class SetGetExample {\n\n    public void run() {\n        RedisClient redisClient = RedisClient.create(\"redis://localhost:6379\");\n\n        try (StatefulRedisConnection<String, String> connection = redisClient.connect()) {\n            RedisReactiveCommands<String, String> reactiveCommands = connection.reactive();\n\n\n            Mono<Void> setGetExample = reactiveCommands.set(\"bike:1\", \"Process 134\")\n                    .doOnNext(res1 -> {\n                        System.out.println(res1); // >>> OK\n                    })\n                    .then(reactiveCommands.get(\"bike:1\"))\n                    .doOnNext(res2 -> {\n                        System.out.println(res2); // >>> Process 134\n                    })\n                    .then();\n\n            setGetExample.block();\n        } finally {\n            redisClient.shutdown();\n        }\n    }\n}",
      "section_id": "store-and-retrieve-data"
    },
    {
      "id": "store-and-retrieve-data-ex5",
      "language": "java",
      "code": "package io.redis.examples;\n\nimport redis.clients.jedis.RedisClient;\n\n\npublic class SetGetExample {\n\n  public void run() {\n\n    RedisClient jedis = RedisClient.create(\"redis://localhost:6379\");\n\n    String status = jedis.set(\"bike:1\", \"Process 134\");\n\n    if (\"OK\".equals(status)) System.out.println(\"Successfully added a bike.\");\n\n    String value = jedis.get(\"bike:1\");\n\n    if (value != null) System.out.println(\"The name of the bike is: \" + value + \".\");\n\n\n    jedis.close();\n  }\n}",
      "section_id": "store-and-retrieve-data"
    },
    {
      "id": "store-and-retrieve-data-ex6",
      "language": "javascript",
      "code": "import { createClient } from 'redis';\n\nconst client = createClient();\n\nclient.on('error', err => console.log('Redis Client Error', err));\n\nawait client.connect().catch(console.error);\n\nawait client.set('bike:1', 'Process 134');\nconst value = await client.get('bike:1');\nconsole.log(value);\n// returns 'Process 134'\n\nawait client.close();",
      "section_id": "store-and-retrieve-data"
    },
    {
      "id": "store-and-retrieve-data-ex7",
      "language": "javascript",
      "code": "import assert from 'node:assert';\nimport { Redis } from 'ioredis';\n\nconst redis = new Redis();\n\n\nconst res1 = await redis.set('bike:1', 'Process 134');\nconsole.log(res1); // >>> OK\n\nconst res2 = await redis.get('bike:1');\nconsole.log(res2); // >>> Process 134\n\n\nredis.disconnect();",
      "section_id": "store-and-retrieve-data"
    },
    {
      "id": "store-and-retrieve-data-ex8",
      "language": "javascript",
      "code": "import { createClient } from 'redis';\n\nconst client = createClient();\n\nclient.on('error', err => console.log('Redis Client Error', err));\n\nawait client.connect().catch(console.error);\n\nawait client.set('bike:1', 'Process 134');\nconst value = await client.get('bike:1');\nconsole.log(value);\n// returns 'Process 134'\n\nawait client.close();",
      "section_id": "store-and-retrieve-data"
    },
    {
      "id": "store-and-retrieve-data-ex9",
      "language": "javascript",
      "code": "import assert from 'node:assert';\nimport { Redis } from 'ioredis';\n\nconst redis = new Redis();\n\n\nconst res1 = await redis.set('bike:1', 'Process 134');\nconsole.log(res1); // >>> OK\n\nconst res2 = await redis.get('bike:1');\nconsole.log(res2); // >>> Process 134\n\n\nredis.disconnect();",
      "section_id": "store-and-retrieve-data"
    },
    {
      "id": "store-and-retrieve-data-ex10",
      "language": "php",
      "code": "<?php\nuse Predis\\Client as PredisClient;\n\nclass SetGetTest\n{\n    public function testSetGet() {\n        $r = new PredisClient([\n            'scheme'   => 'tcp',\n            'host'     => '127.0.0.1',\n            'port'     => 6379,\n            'password' => '',\n            'database' => 0,\n        ]);\n\n\n        $res1 = $r->set('bike:1', 'Process 134');\n        echo $res1 . PHP_EOL; // >>> OK\n\n        $res2 = $r->get('bike:1');\n        echo $res2 . PHP_EOL; // >>> Process 134\n\n    }\n}",
      "section_id": "store-and-retrieve-data"
    },
    {
      "id": "store-and-retrieve-data-ex11",
      "language": "python",
      "code": "\"\"\"\nCode samples for data structure store quickstart pages:\n    https://redis.io/docs/latest/develop/get-started/data-store/\n\"\"\"\n\nimport redis\n\nr = redis.Redis(host=\"localhost\", port=6379, db=0, decode_responses=True)\n\nres = r.set(\"bike:1\", \"Process 134\")\nprint(res)\n# >>> True\n\nres = r.get(\"bike:1\")\nprint(res)\n# >>> \"Process 134\"",
      "section_id": "store-and-retrieve-data"
    },
    {
      "id": "store-and-retrieve-data-ex12",
      "language": "ruby",
      "code": "require 'redis'\n\nr = Redis.new\n\n\nres1 = r.set('bike:1', 'Process 134')\nputs res1 # >>> OK\n\nres2 = r.get('bike:1')\nputs res2 # >>> Process 134",
      "section_id": "store-and-retrieve-data"
    },
    {
      "id": "store-and-retrieve-data-ex13",
      "language": "rust",
      "code": "mod set_and_get_tests {\n    use redis::AsyncCommands;\n\n    async fn run() {\n        let mut r = match redis::Client::open(\"redis://127.0.0.1\") {\n            Ok(client) => match client.get_multiplexed_async_connection().await {\n                Ok(conn) => conn,\n                Err(e) => {\n                    println!(\"Failed to connect to Redis: {e}\");\n                    return;\n                }\n            },\n            Err(e) => {\n                println!(\"Failed to create Redis client: {e}\");\n                return;\n            }\n        };\n\n\n        if let Ok(res1) = r.set(\"bike:1\", \"Process 134\").await {\n            let res1: String = res1;\n            println!(\"{res1}\"); // >>> OK\n        }\n\n        if let Ok(res2) = r.get(\"bike:1\").await {\n            let res2: String = res2;\n            println!(\"{res2}\"); // >>> Process 134\n        }\n\n    }\n}",
      "section_id": "store-and-retrieve-data"
    },
    {
      "id": "store-and-retrieve-data-ex14",
      "language": "rust",
      "code": "mod set_and_get_tests {\n    use redis::Commands;\n\n    fn run() {\n        let mut r = match redis::Client::open(\"redis://127.0.0.1\") {\n            Ok(client) => match client.get_connection() {\n                Ok(conn) => conn,\n                Err(e) => {\n                    println!(\"Failed to connect to Redis: {e}\");\n                    return;\n                }\n            },\n            Err(e) => {\n                println!(\"Failed to create Redis client: {e}\");\n                return;\n            }\n        };\n\n\n        if let Ok(res1) = r.set(\"bike:1\", \"Process 134\") {\n            let res1: String = res1;\n            println!(\"{res1}\"); // >>> OK\n        }\n\n        if let Ok(res2) = r.get(\"bike:1\") {\n            let res2: String = res2;\n            println!(\"{res2}\"); // >>> Process 134\n        }\n\n    }\n}",
      "section_id": "store-and-retrieve-data"
    },
    {
      "id": "store-and-retrieve-data-ex15",
      "language": "plaintext",
      "code": "> HSET bike:2 model Deimos brand Ergonom type 'Enduro bikes' price 4972\n(integer) 4\n> HGET bike:2 model\n\"Deimos\"\n> HGET bike:2 price\n\"4972\"\n> HGETALL bike:2\n1) \"model\"\n2) \"Deimos\"\n3) \"brand\"\n4) \"Ergonom\"\n5) \"type\"\n6) \"Enduro bikes\"\n7) \"price\"\n8) \"4972\"",
      "section_id": "store-and-retrieve-data"
    },
    {
      "id": "store-and-retrieve-data-ex16",
      "language": "csharp",
      "code": "db.HashSet(\"bike:1\", [\n            new(\"model\", \"Deimos\"),\n            new(\"brand\", \"Ergonom\"),\n            new(\"type\", \"Enduro bikes\"),\n            new(\"price\", 4972)\n        ]);\n\n        Console.WriteLine(\"Hash Created\");\n        // Hash Created\n\n        var model = db.HashGet(\"bike:1\", \"model\");\n        Console.WriteLine($\"Model: {model}\");\n        // Model: Deimos\n\n        var price = db.HashGet(\"bike:1\", \"price\");\n        Console.WriteLine($\"Price: {price}\");\n        // Price: 4972\n\n        var bike = db.HashGetAll(\"bike:1\");\n        Console.WriteLine(\"bike:1\");\n        Console.WriteLine(string.Join(\"\\n\", bike.Select(b => $\"{b.Name}: {b.Value}\")));\n        // Bike:1:\n        // model: Deimos\n        // brand: Ergonom\n        // type: Enduro bikes\n        // price: 4972",
      "section_id": "store-and-retrieve-data"
    },
    {
      "id": "store-and-retrieve-data-ex17",
      "language": "go",
      "code": "hashFields := []string{\n\t\t\"model\", \"Deimos\",\n\t\t\"brand\", \"Ergonom\",\n\t\t\"type\", \"Enduro bikes\",\n\t\t\"price\", \"4972\",\n\t}\n\n\tres1, err := rdb.HSet(ctx, \"bike:1\", hashFields).Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(res1) // >>> 4\n\n\tres2, err := rdb.HGet(ctx, \"bike:1\", \"model\").Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(res2) // >>> Deimos\n\n\tres3, err := rdb.HGet(ctx, \"bike:1\", \"price\").Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(res3) // >>> 4972\n\n\tcmdReturn := rdb.HGetAll(ctx, \"bike:1\")\n\tres4, err := cmdReturn.Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(res4)\n\t// >>> map[brand:Ergonom model:Deimos price:4972 type:Enduro bikes]\n\n\ttype BikeInfo struct {\n\t\tModel string `redis:\"model\"`\n\t\tBrand string `redis:\"brand\"`\n\t\tType  string `redis:\"type\"`\n\t\tPrice int    `redis:\"price\"`\n\t}\n\n\tvar res4a BikeInfo\n\n\tif err := cmdReturn.Scan(&res4a); err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Printf(\"Model: %v, Brand: %v, Type: %v, Price: $%v\\n\",\n\t\tres4a.Model, res4a.Brand, res4a.Type, res4a.Price)\n\t// >>> Model: Deimos, Brand: Ergonom, Type: Enduro bikes, Price: $4972",
      "section_id": "store-and-retrieve-data"
    },
    {
      "id": "store-and-retrieve-data-ex18",
      "language": "java",
      "code": "Map<String, String> bike1 = new HashMap<>();\n            bike1.put(\"model\", \"Deimos\");\n            bike1.put(\"brand\", \"Ergonom\");\n            bike1.put(\"type\", \"Enduro bikes\");\n            bike1.put(\"price\", \"4972\");\n\n            CompletableFuture<Void> setGetAll = asyncCommands.hset(\"bike:1\", bike1).thenCompose(res1 -> {\n                System.out.println(res1); // >>> 4\n                return asyncCommands.hget(\"bike:1\", \"model\");\n            }).thenCompose(res2 -> {\n                System.out.println(res2); // >>> Deimos\n                return asyncCommands.hget(\"bike:1\", \"price\");\n            }).thenCompose(res3 -> {\n                System.out.println(res3); // >>> 4972\n                return asyncCommands.hgetall(\"bike:1\");\n            })\n                    .thenAccept(System.out::println)\n                    // >>> {type=Enduro bikes, brand=Ergonom, price=4972, model=Deimos}\n                    .toCompletableFuture();",
      "section_id": "store-and-retrieve-data"
    },
    {
      "id": "store-and-retrieve-data-ex19",
      "language": "java",
      "code": "Map<String, String> bike1 = new HashMap<>();\n            bike1.put(\"model\", \"Deimos\");\n            bike1.put(\"brand\", \"Ergonom\");\n            bike1.put(\"type\", \"Enduro bikes\");\n            bike1.put(\"price\", \"4972\");\n\n            Mono<Long> setGetAll = reactiveCommands.hset(\"bike:1\", bike1).doOnNext(result -> {\n                System.out.println(result); // >>> 4\n            });\n\n            setGetAll.block();\n\n            Mono<String> getModel = reactiveCommands.hget(\"bike:1\", \"model\").doOnNext(result -> {\n                System.out.println(result); // >>> Deimos\n            });\n\n            Mono<String> getPrice = reactiveCommands.hget(\"bike:1\", \"price\").doOnNext(result -> {\n                System.out.println(result); // >>> 4972\n            });\n\n            Mono<List<KeyValue<String, String>>> getAll = reactiveCommands.hgetall(\"bike:1\").collectList().doOnNext(result -> {\n                System.out.println(result);\n                // >>> [KeyValue[type, Enduro bikes], KeyValue[brand, Ergonom],\n                // KeyValue[price, 4972], KeyValue[model, Deimos]]\n            });",
      "section_id": "store-and-retrieve-data"
    },
    {
      "id": "store-and-retrieve-data-ex20",
      "language": "java",
      "code": "Map<String, String> bike1 = new HashMap<>();\n      bike1.put(\"model\", \"Deimos\");\n      bike1.put(\"brand\", \"Ergonom\");\n      bike1.put(\"type\", \"Enduro bikes\");\n      bike1.put(\"price\", \"4972\");\n\n      Long res1 = jedis.hset(\"bike:1\", bike1);\n      System.out.println(res1); // 4\n\n      String res2 = jedis.hget(\"bike:1\", \"model\");\n      System.out.println(res2); // Deimos\n\n      String res3 = jedis.hget(\"bike:1\", \"price\");\n      System.out.println(res3); // 4972\n\n      Map<String, String> res4 = jedis.hgetAll(\"bike:1\");\n      System.out.println(res4); // {type=Enduro bikes, brand=Ergonom, price=4972, model=Deimos}",
      "section_id": "store-and-retrieve-data"
    },
    {
      "id": "store-and-retrieve-data-ex21",
      "language": "javascript",
      "code": "const res1 = await client.hSet(\n  'bike:1',\n  {\n    'model': 'Deimos',\n    'brand': 'Ergonom',\n    'type': 'Enduro bikes',\n    'price': 4972,\n  }\n)\nconsole.log(res1) // 4\n\nconst res2 = await client.hGet('bike:1', 'model')\nconsole.log(res2)  // 'Deimos'\n\nconst res3 = await client.hGet('bike:1', 'price')\nconsole.log(res3)  // '4972'\n\nconst res4 = await client.hGetAll('bike:1')\nconsole.log(res4)  \n/*\n{\n  brand: 'Ergonom',\n  model: 'Deimos',\n  price: '4972',\n  type: 'Enduro bikes'\n}\n*/",
      "section_id": "store-and-retrieve-data"
    },
    {
      "id": "store-and-retrieve-data-ex22",
      "language": "php",
      "code": "$res1 = $r->hmset('bike:1', [\n            'model' => 'Deimos',\n            'brand' => 'Ergonom',\n            'type' => 'Enduro bikes',\n            'price' => 4972,\n        ]);\n\n        echo $res1 . PHP_EOL;\n        // >>> 4\n\n        $res2 = $r->hget('bike:1', 'model');\n        echo $res2 . PHP_EOL;\n        // >>> Deimos\n\n        $res3 = $r->hget('bike:1', 'price');\n        echo $res3 . PHP_EOL;\n        // >>> 4972\n\n        $res4 = $r->hgetall('bike:1');\n        echo json_encode($res3) . PHP_EOL;\n        // >>> {\"name\":\"Deimos\",\"brand\":\"Ergonom\",\"type\":\"Enduro bikes\",\"price\":\"4972\"}",
      "section_id": "store-and-retrieve-data"
    },
    {
      "id": "store-and-retrieve-data-ex23",
      "language": "python",
      "code": "res1 = r.hset(\n    \"bike:1\",\n    mapping={\n        \"model\": \"Deimos\",\n        \"brand\": \"Ergonom\",\n        \"type\": \"Enduro bikes\",\n        \"price\": 4972,\n    },\n)\nprint(res1)\n# >>> 4\n\nres2 = r.hget(\"bike:1\", \"model\")\nprint(res2)\n# >>> 'Deimos'\n\nres3 = r.hget(\"bike:1\", \"price\")\nprint(res3)\n# >>> '4972'\n\nres4 = r.hgetall(\"bike:1\")\nprint(res4)\n# >>> {'model': 'Deimos', 'brand': 'Ergonom', 'type': 'Enduro bikes', 'price': '4972'}",
      "section_id": "store-and-retrieve-data"
    },
    {
      "id": "store-and-retrieve-data-ex24",
      "language": "ruby",
      "code": "res1 = r.hset('bike:1', {\n  'model' => 'Deimos',\n  'brand' => 'Ergonom',\n  'type' => 'Enduro bikes',\n  'price' => 4972\n})\nputs res1 # >>> 4\n\nres2 = r.hget('bike:1', 'model')\nputs res2 # >>> Deimos\n\nres3 = r.hget('bike:1', 'price')\nputs res3 # >>> 4972\n\nres4 = r.hgetall('bike:1')\nputs res4.inspect\n# >>> {\"model\" => \"Deimos\", \"brand\" => \"Ergonom\", \"type\" => \"Enduro bikes\", \"price\" => \"4972\"}",
      "section_id": "store-and-retrieve-data"
    },
    {
      "id": "store-and-retrieve-data-ex25",
      "language": "rust",
      "code": "let hash_fields = [\n            (\"model\", \"Deimos\"),\n            (\"brand\", \"Ergonom\"),\n            (\"type\", \"Enduro bikes\"),\n            (\"price\", \"4972\"),\n        ];\n\n        if let Ok(res) = r.hset_multiple(\"bike:1\", &hash_fields).await {\n            let res: String = res;\n            println!(\"{res}\");    // >>> OK\n        }\n\n        match r.hget(\"bike:1\", \"model\").await {\n            Ok(res) => {\n                let res: String = res;\n                println!(\"{res}\");   // >>> Deimos\n            },\n            Err(e) => {\n                println!(\"Error getting bike:1 model: {e}\");\n                return;\n            }\n        };\n\n        match r.hget(\"bike:1\", \"price\").await {\n            Ok(res) => {\n                let res: String = res;\n                println!(\"{res}\");   // >>> 4972\n            },\n            Err(e) => {\n                println!(\"Error getting bike:1 price: {e}\");\n                return;\n            }\n        };\n\n        match r.hgetall(\"bike:1\").await {\n            Ok(res) => {\n                let res: Vec<(String, String)> = res;\n                println!(\"{res:?}\");\n                // >>> [(\"model\", \"Deimos\"), (\"brand\", \"Ergonom\"), (\"type\", \"Enduro bikes\"), (\"price\", \"4972\")]\n            },\n            Err(e) => {\n                println!(\"Error getting bike:1: {e}\");\n                return;\n            }\n        };",
      "section_id": "store-and-retrieve-data"
    },
    {
      "id": "store-and-retrieve-data-ex26",
      "language": "rust",
      "code": "let hash_fields = [\n            (\"model\", \"Deimos\"),\n            (\"brand\", \"Ergonom\"),\n            (\"type\", \"Enduro bikes\"),\n            (\"price\", \"4972\"),\n        ];\n\n        if let Ok(res) = r.hset_multiple(\"bike:1\", &hash_fields) {\n            let res: String = res;\n            println!(\"{res}\");    // >>> OK\n        }\n\n        match r.hget(\"bike:1\", \"model\") {\n            Ok(res) => {\n                let res: String = res;\n                println!(\"{res}\");   // >>> Deimos\n            },\n            Err(e) => {\n                println!(\"Error getting bike:1 model: {e}\");\n                return;\n            }\n        };\n\n        match r.hget(\"bike:1\", \"price\") {\n            Ok(res) => {\n                let res: String = res;\n                println!(\"{res}\");   // >>> 4972\n            },\n            Err(e) => {\n                println!(\"Error getting bike:1 price: {e}\");\n                return;\n            }\n        };\n\n        match r.hgetall(\"bike:1\") {\n            Ok(res) => {\n                let res: Vec<(String, String)> = res;\n                println!(\"{res:?}\");\n                // >>> [(\"model\", \"Deimos\"), (\"brand\", \"Ergonom\"), (\"type\", \"Enduro bikes\"), (\"price\", \"4972\")]\n            },\n            Err(e) => {\n                println!(\"Error getting bike:1: {e}\");\n                return;\n            }\n        };",
      "section_id": "store-and-retrieve-data"
    },
    {
      "id": "scan-the-keyspace-ex0",
      "language": "plaintext",
      "code": "SCAN 0 MATCH \"bike:*\" COUNT 100",
      "section_id": "scan-the-keyspace"
    }
  ]
}
