{
  "schema_version": 2,
  "id": "develop/data-types/strings",
  "title": "Redis Strings",
  "url": "https://redis.io/docs/latest/develop/data-types/strings/",
  "summary": "Introduction to Redis strings",
  "aliases": [
    "/data-types/strings/",
    "/manual/data-types/strings/",
    "/develop/data-types/string/"
  ],
  "tags": [
    "docs",
    "develop",
    "stack",
    "oss",
    "rs",
    "rc",
    "kubernetes",
    "clients"
  ],
  "last_updated": "2026-10-12T11:44:13+01:00",
  "children": [
    {
      "id": "develop/data-types/strings/bitfields",
      "summary": "Introduction to Redis bitfields",
      "title": "Redis bitfields",
      "url": "https://redis.io/docs/latest/develop/data-types/strings/bitfields/"
    },
    {
      "id": "develop/data-types/strings/bitmaps",
      "summary": "Introduction to Redis bitmaps",
      "title": "Redis bitmaps",
      "url": "https://redis.io/docs/latest/develop/data-types/strings/bitmaps/"
    }
  ],
  "page_type": "content",
  "content_hash": "c0d482c4d1be20a4d92f3f7ee04673bdfb33ced1eeaf25b3fd3ff2956575eaa7",
  "sections": [
    {
      "id": "string-command-summary",
      "title": "String command summary",
      "role": "content",
      "text": "**26 commands in this group:**\n\n[View all string commands](https://redis.io/commands/?group=string)\n\n| Command | Summary | Complexity | Since |\n|---------|---------|------------|-------|\n| [APPEND](https://redis.io/commands/append/) | Appends a string to the value of a key. Creates the key if it doesn't exist. | O(1). The amortized time complexity is O(1) ass... | 2.0.0 |\n| [DECR](https://redis.io/commands/decr/) | Decrements the integer value of a key by one. Uses 0 as initial value if the key doesn't exist. | O(1) | 1.0.0 |\n| [DECRBY](https://redis.io/commands/decrby/) | Decrements a number from the integer value of a key. Uses 0 as initial value if the key doesn't exist. | O(1) | 1.0.0 |\n| [DELEX](https://redis.io/commands/delex/) | Conditionally removes the specified key based on value or digest comparison. | O(1) for IFEQ/IFNE, O(N) for IFDEQ/IFDNE where ... | 8.4.0 |\n| [DIGEST](https://redis.io/commands/digest/) | Returns the XXH3 hash of a string value. | O(N) where N is the length of the string value. | 8.4.0 |\n| [GET](https://redis.io/commands/get/) | Returns the string value of a key. | O(1) | 1.0.0 |\n| [GETDEL](https://redis.io/commands/getdel/) | Returns the string value of a key after deleting the key. | O(1) | 6.2.0 |\n| [GETEX](https://redis.io/commands/getex/) | Returns the string value of a key after setting its expiration time. | O(1) | 6.2.0 |\n| [GETRANGE](https://redis.io/commands/getrange/) | Returns a substring of the string stored at a key. | O(N) where N is the length of the returned stri... | 2.4.0 |\n| [GETSET](https://redis.io/commands/getset/) | Returns the previous string value of a key after setting it to a new value. | O(1) | 1.0.0 |\n\n#### String command summary (part 2)\n\n| Command | Summary | Complexity | Since |\n|---------|---------|------------|-------|\n| [INCR](https://redis.io/commands/incr/) | Increments the integer value of a key by one. Uses 0 as initial value if the key doesn't exist. | O(1) | 1.0.0 |\n| [INCRBY](https://redis.io/commands/incrby/) | Increments the integer value of a key by a number. Uses 0 as initial value if the key doesn't exist. | O(1) | 1.0.0 |\n| [INCRBYFLOAT](https://redis.io/commands/incrbyfloat/) | Increment the floating point value of a key by a number. Uses 0 as initial value if the key doesn't exist. | O(1) | 2.6.0 |\n| [INCREX](https://redis.io/commands/increx/) | Increments the numeric value of a key by a number and sets its expiration time. Uses 0 as initial value if the key doesn't exist. | O(1) | 8.8.0 |\n| [LCS](https://redis.io/commands/lcs/) | Finds the longest common substring. | O(N*M) where N and M are the lengths of s1 and ... | 7.0.0 |\n| [MGET](https://redis.io/commands/mget/) | Atomically returns the string values of one or more keys. | O(N) where N is the number of keys to retrieve. | 1.0.0 |\n| [MSET](https://redis.io/commands/mset/) | Atomically creates or modifies the string values of one or more keys. | O(N) where N is the number of keys to set. | 1.0.1 |\n| [MSETEX](https://redis.io/commands/msetex/) | Atomically sets multiple string keys with a shared expiration in a single operation. Supports flexible argument parsing where condition and expiration flags can appear in any order. | O(N) where N is the number of keys to set. | 8.4.0 |\n| [MSETNX](https://redis.io/commands/msetnx/) | Atomically modifies the string values of one or more keys only when all keys don't exist. | O(N) where N is the number of keys to set. | 1.0.1 |\n| [PSETEX](https://redis.io/commands/psetex/) | Sets both string value and expiration time in milliseconds of a key. The key is created if it doesn't exist. | O(1) | 2.6.0 |\n\n#### String command summary (part 3)\n\n| Command | Summary | Complexity | Since |\n|---------|---------|------------|-------|\n| [SET](https://redis.io/commands/set/) | Sets the string value of a key, ignoring its type. The key is created if it doesn't exist. | O(1) | 1.0.0 |\n| [SETEX](https://redis.io/commands/setex/) | Sets the string value and expiration time of a key. Creates the key if it doesn't exist. | O(1) | 2.0.0 |\n| [SETNX](https://redis.io/commands/setnx/) | Set the string value of a key only when the key doesn't exist. | O(1) | 1.0.0 |\n| [SETRANGE](https://redis.io/commands/setrange/) | Overwrites a part of a string value with another by an offset. Creates the key if it doesn't exist. | O(1), not counting the time taken to copy the n... | 2.2.0 |\n| [STRLEN](https://redis.io/commands/strlen/) | Returns the length of a string value. | O(1) | 2.2.0 |\n| [SUBSTR](https://redis.io/commands/substr/) | Returns a substring from a string value. | O(N) where N is the length of the returned stri... | 1.0.0 |\n\n\n\nRedis strings store sequences of bytes, including text, serialized objects, and binary arrays.\nAs such, strings are the simplest type of value you can associate with a Redis key.\nThey're often used for caching, but they support additional functionality that lets you implement counters and perform bitwise operations, too.\n\nSince Redis keys are strings, when we use the string type as a value too,\nwe are mapping a string to another string. The string data type is useful\nfor a number of use cases, like caching HTML fragments or pages.\n\nFoundational: Set and retrieve string values using SET and GET (overwrites existing values)\n\n**Commands:** SET, GET\n\n**Complexity:**\n- SET: O(1)\n- GET: O(1)\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\nAs you can see using the [`SET`](https://redis.io/docs/latest/commands/set) and the [`GET`](https://redis.io/docs/latest/commands/get) commands are the way we set\nand retrieve a string value. Note that [`SET`](https://redis.io/docs/latest/commands/set) will replace any existing value\nalready stored into the key, in the case that the key already exists, even if\nthe key is associated with a non-string value. So [`SET`](https://redis.io/docs/latest/commands/set) performs an assignment.\n\nValues can be strings (including binary data) of every kind, for instance you\ncan store a jpeg image inside a value. A value can't be bigger than 512 MB.\n\nThe [`SET`](https://redis.io/docs/latest/commands/set) command has interesting options that are provided as additional\narguments. For example, I may ask [`SET`](https://redis.io/docs/latest/commands/set) to fail if the key already exists,\nor the opposite, that it only succeed if the key already exists:\n\nConditional SET operations: Use NX and XX options to set a key only if it doesn't exist yet, or only if it already exists\n\n**Difficulty:** Intermediate\n\n**Builds upon:** set_get\n\n**Commands:** SET\n\n**Complexity:**\n- SET: O(1)\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\nStarting with Redis 8.4, [`SET`](https://redis.io/docs/latest/commands/set) can also check the key's current value before it writes.\nWith the `IFEQ` option, `SET` succeeds only if the current value equals the one you pass.\nThis lets a client update a value it read earlier without overwriting a change that another client made in the meantime, a pattern known as compare-and-swap (CAS).\nThe [`DELEX`](https://redis.io/docs/latest/commands/delex) command applies the same check to deletion (compare-and-delete):\n\nCompare-and-swap and compare-and-delete: Use the IFEQ option with SET and DELEX to update or delete a key only if its value hasn't changed since you read it\n\n**Difficulty:** Intermediate\n\n**Builds upon:** setnx_xx\n\n**Commands:** SET, GET, DELEX\n\n**Complexity:**\n- SET: O(1)\n- GET: O(1)\n- DELEX: O(1)\n\n**Available in:** Redis CLI, C#, Go, Java (Asynchronous - Lettuce), Java (Reactive - Lettuce), Java (Synchronous - Jedis), JavaScript (Node.js), PHP, Python, 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##### Rust (Asynchronous)\n\n[code example]\n\n##### Rust (Synchronous)\n\n[code example]\n\n\n\nThe `IFNE` option reverses the check, and the `IFDEQ` and `IFDNE` options compare a hash digest of the value instead of the value itself.\nUse [`DIGEST`](https://redis.io/docs/latest/commands/digest) to get the digest of a key's value.\n\nThere are a number of other commands for operating on strings. For example\nthe [`GETSET`](https://redis.io/docs/latest/commands/getset) command sets a key to a new value, returning the old value as the\nresult. You can use this command, for example, if you have a\nsystem that increments a Redis key using [`INCR`](https://redis.io/docs/latest/commands/incr)\nevery time your web site receives a new visitor. You may want to collect this\ninformation once every hour, without losing a single increment.\nYou can [`GETSET`](https://redis.io/docs/latest/commands/getset) the key, assigning it the new value of \"0\" and reading the\nold value back.\n\nThe ability to set or retrieve the value of multiple keys in a single\ncommand is also useful for reduced latency. For this reason there are\nthe [`MSET`](https://redis.io/docs/latest/commands/mset) and [`MGET`](https://redis.io/docs/latest/commands/mget) commands:\n\nSet and retrieve multiple values using MSET and MGET when you need to reduce round trips to the server\n\n**Builds upon:** set_get\n\n**Commands:** MSET, MGET\n\n**Complexity:**\n- MSET: O(N)\n- MGET: 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\nWhen [`MGET`](https://redis.io/docs/latest/commands/mget) is used, Redis returns an array of values."
    },
    {
      "id": "strings-as-counters",
      "title": "Strings as counters",
      "role": "content",
      "text": "Even if strings are the basic values of Redis, there are interesting operations\nyou can perform with them. For instance, one is atomic increment:\n\nAtomic counters: Increment string values using INCR and INCRBY when you need thread-safe operations (initializes to 0 if key doesn't exist)\n\n**Builds upon:** set_get\n\n**Commands:** SET, INCR, INCRBY\n\n**Complexity:**\n- SET: O(1)\n- INCR: O(1)\n- INCRBY: O(1)\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\nThe [`INCR`](https://redis.io/docs/latest/commands/incr) command parses the string value as an integer,\nincrements it by one, and finally sets the obtained value as the new value.\nThere are other similar commands like [`INCRBY`](https://redis.io/docs/latest/commands/incrby),\n[`DECR`](https://redis.io/docs/latest/commands/decr) and [`DECRBY`](https://redis.io/docs/latest/commands/decrby). Internally it's\nalways the same command, acting in a slightly different way.\n\nWhat does it mean that INCR is atomic?\nThat even multiple clients issuing INCR against\nthe same key will never enter into a race condition. For instance, it will never\nhappen that client 1 reads \"10\", client 2 reads \"10\" at the same time, both\nincrement to 11, and set the new value to 11. The final value will always be\n12 and the read-increment-set operation is performed while all the other\nclients are not executing a command at the same time."
    },
    {
      "id": "limits",
      "title": "Limits",
      "role": "limits",
      "text": "By default, a single Redis string can be a maximum of 512 MB."
    },
    {
      "id": "bitwise-and-bitfield-operations",
      "title": "Bitwise and bitfield operations",
      "role": "content",
      "text": "To perform bitwise operations on a string, see the [bitmaps data type](https://redis.io/docs/latest/develop/data-types/strings/bitmaps) docs. To store and manipulate integer values within a string, see the [bitfields data type](https://redis.io/docs/latest/develop/data-types/strings/bitfields) docs."
    },
    {
      "id": "performance",
      "title": "Performance",
      "role": "performance",
      "text": "Most string operations are O(1), which means they're highly efficient.\nHowever, be careful with the [`SUBSTR`](https://redis.io/docs/latest/commands/substr), [`GETRANGE`](https://redis.io/docs/latest/commands/getrange), and [`SETRANGE`](https://redis.io/docs/latest/commands/setrange) commands, which can be O(n).\nThese random-access string commands may cause performance issues when dealing with large strings."
    },
    {
      "id": "alternatives",
      "title": "Alternatives",
      "role": "content",
      "text": "If you're storing structured data as a serialized string, you may also want to consider Redis [hashes](https://redis.io/docs/latest/develop/data-types/hashes) or [JSON](https://redis.io/docs/latest/develop/data-types/json)."
    },
    {
      "id": "learn-more",
      "title": "Learn more",
      "role": "related",
      "text": "* [Redis Strings Explained](https://www.youtube.com/watch?v=7CUt4yWeRQE) is a short, comprehensive video explainer on Redis strings.\n* [Redis University's RU101](https://university.redis.com/courses/ru101/) covers Redis strings in detail."
    }
  ],
  "examples": [
    {
      "id": "string-command-summary-ex0",
      "language": "plaintext",
      "code": "> SET bike:1 Deimos\nOK\n> GET bike:1\n\"Deimos\"",
      "section_id": "string-command-summary"
    },
    {
      "id": "string-command-summary-ex1",
      "language": "csharp",
      "code": "var res1 = db.StringSet(\"bike:1\", \"Deimos\");\n        Console.WriteLine(res1); // true\n        var res2 = db.StringGet(\"bike:1\");\n        Console.WriteLine(res2); // Deimos",
      "section_id": "string-command-summary"
    },
    {
      "id": "string-command-summary-ex2",
      "language": "go",
      "code": "res1, err := rdb.Set(ctx, \"bike:1\", \"Deimos\", 0).Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(res1) // >>> OK\n\n\tres2, err := rdb.Get(ctx, \"bike:1\").Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(res2) // >>> Deimos",
      "section_id": "string-command-summary"
    },
    {
      "id": "string-command-summary-ex3",
      "language": "java",
      "code": "CompletableFuture<Void> setAndGet = asyncCommands.set(\"bike:1\", \"Deimos\").thenCompose(v -> {\n                System.out.println(v); // >>> OK\n                return asyncCommands.get(\"bike:1\");\n            })\n                    .thenAccept(System.out::println) // >>> Deimos\n                    .toCompletableFuture();",
      "section_id": "string-command-summary"
    },
    {
      "id": "string-command-summary-ex4",
      "language": "java",
      "code": "Mono<Void> setAndGet = reactiveCommands.set(\"bike:1\", \"Deimos\").doOnNext(v -> {\n                System.out.println(v); // OK\n            }).flatMap(v -> reactiveCommands.get(\"bike:1\")).doOnNext(res -> {\n                System.out.println(res); // Deimos\n            }).then();",
      "section_id": "string-command-summary"
    },
    {
      "id": "string-command-summary-ex5",
      "language": "java",
      "code": "String res1 = jedis.set(\"bike:1\", \"Deimos\");\n      System.out.println(res1); // OK\n      String res2 = jedis.get(\"bike:1\");\n      System.out.println(res2); // Deimos",
      "section_id": "string-command-summary"
    },
    {
      "id": "string-command-summary-ex6",
      "language": "javascript",
      "code": "const res1 = await client.set(\"bike:1\", \"Deimos\");\nconsole.log(res1);  // OK\nconst res2 = await client.get(\"bike:1\");\nconsole.log(res2);  // Deimos",
      "section_id": "string-command-summary"
    },
    {
      "id": "string-command-summary-ex7",
      "language": "php",
      "code": "$res1 = $r->set('bike:1', 'Deimos');\n        echo \"$res1\" . PHP_EOL;\n        // >>> OK\n\n        $res2 = $r->get('bike:1');\n        echo \"$res2\" . PHP_EOL;\n        // >>> Deimos",
      "section_id": "string-command-summary"
    },
    {
      "id": "string-command-summary-ex8",
      "language": "python",
      "code": "res1 = r.set(\"bike:1\", \"Deimos\")\nprint(res1)  # True\nres2 = r.get(\"bike:1\")\nprint(res2)  # Deimos",
      "section_id": "string-command-summary"
    },
    {
      "id": "string-command-summary-ex9",
      "language": "ruby",
      "code": "res1 = r.set('bike:1', 'Deimos')\nputs res1 # >>> OK\n\nres2 = r.get('bike:1')\nputs res2 # >>> Deimos",
      "section_id": "string-command-summary"
    },
    {
      "id": "string-command-summary-ex10",
      "language": "rust",
      "code": "if let Ok(res) = r.set(\"bike:1\", \"Deimos\").await {\n            let res: String = res;\n            println!(\"{res}\");    // >>> OK\n        }\n\n        match r.get(\"bike:1\").await {\n            Ok(res) => {\n                let res: String = res;\n                println!(\"{res}\");   // >>> Deimos\n            },\n            Err(e) => {\n                println!(\"Error getting foo: {e}\");\n                return;\n            }\n        };",
      "section_id": "string-command-summary"
    },
    {
      "id": "string-command-summary-ex11",
      "language": "rust",
      "code": "if let Ok(res) = r.set(\"bike:1\", \"Deimos\") {\n            let res: String = res;\n            println!(\"{res}\");    // >>> OK\n        }\n\n        match r.get(\"bike:1\") {\n            Ok(res) => {\n                let res: String = res;\n                println!(\"{res}\");   // >>> Deimos\n            },\n            Err(e) => {\n                println!(\"Error getting bike:1: {e}\");\n                return;\n            }\n        };",
      "section_id": "string-command-summary"
    },
    {
      "id": "string-command-summary-ex12",
      "language": "plaintext",
      "code": "# Recreate the bike:1 key so this example runs on its own.\n> SET bike:1 Deimos\nOK\n> SET bike:1 bike NX\n(nil)\n> SET bike:1 bike XX\nOK",
      "section_id": "string-command-summary"
    },
    {
      "id": "string-command-summary-ex13",
      "language": "csharp",
      "code": "// Recreate the bike:1 key so this example runs on its own.\n        db.StringSet(\"bike:1\", \"Deimos\");\n\n        var res3 = db.StringSet(\"bike:1\", \"bike\", when: When.NotExists);\n        Console.WriteLine(res3); // false\n        Console.WriteLine(db.StringGet(\"bike:1\"));\n        var res4 = db.StringSet(\"bike:1\", \"bike\", when: When.Exists);\n        Console.WriteLine(res4); // true",
      "section_id": "string-command-summary"
    },
    {
      "id": "string-command-summary-ex14",
      "language": "go",
      "code": "// Recreate the bike:1 key so this example runs on its own.\n\trdb.Set(ctx, \"bike:1\", \"Deimos\", 0)\n\n\tres3, err := rdb.SetNX(ctx, \"bike:1\", \"bike\", 0).Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(res3) // >>> false\n\n\tres4, err := rdb.Get(ctx, \"bike:1\").Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(res4) // >>> Deimos\n\n\tres5, err := rdb.SetXX(ctx, \"bike:1\", \"bike\", 0).Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(res5) // >>> OK",
      "section_id": "string-command-summary"
    },
    {
      "id": "string-command-summary-ex15",
      "language": "java",
      "code": "// Recreate the bike:1 key so this example runs on its own.\n            CompletableFuture<Void> setnx = asyncCommands.set(\"bike:1\", \"Deimos\")\n                    .thenCompose(setup -> asyncCommands.setnx(\"bike:1\", \"bike\")).thenCompose(v -> {\n                        System.out.println(v); // >>> false (because key already exists)\n                        return asyncCommands.get(\"bike:1\");\n                    })\n                    .thenAccept(System.out::println) // >>> Deimos (value is unchanged)\n                    .toCompletableFuture();\n            setnx.join();\n\n            // set the value to \"bike\" if it already exists\n            CompletableFuture<Void> setxx = asyncCommands.set(\"bike:1\", \"bike\", SetArgs.Builder.xx())\n                    .thenAccept(System.out::println) // >>> OK\n                    .toCompletableFuture();\n            setxx.join();",
      "section_id": "string-command-summary"
    },
    {
      "id": "string-command-summary-ex16",
      "language": "java",
      "code": "// Recreate the bike:1 key so this example runs on its own.\n            Mono<Void> setnx = reactiveCommands.set(\"bike:1\", \"Deimos\")\n                    .flatMap(setup -> reactiveCommands.setnx(\"bike:1\", \"bike\")).doOnNext(v -> {\n                        System.out.println(v); // false (because key already exists)\n                    }).flatMap(v -> reactiveCommands.get(\"bike:1\")).doOnNext(res -> {\n                        System.out.println(res); // Deimos (value is unchanged)\n                    }).then();\n\n            Mono<Void> setxx = reactiveCommands.set(\"bike:1\", \"bike\", SetArgs.Builder.xx()).doOnNext(res -> {\n                System.out.println(res); // OK\n            }).then();",
      "section_id": "string-command-summary"
    },
    {
      "id": "string-command-summary-ex17",
      "language": "java",
      "code": "// Recreate the bike:1 key so this example runs on its own.\n      jedis.set(\"bike:1\", \"Deimos\");\n\n      Long res3 = jedis.setnx(\"bike:1\", \"bike\");\n      System.out.println(res3); // 0 (because key already exists)\n      System.out.println(jedis.get(\"bike:1\")); // Deimos (value is unchanged)\n      String res4 = jedis.set(\"bike:1\", \"bike\", SetParams.setParams().xx()); // set the value to \"bike\" if it\n      // already\n      // exists\n      System.out.println(res4); // OK",
      "section_id": "string-command-summary"
    },
    {
      "id": "string-command-summary-ex18",
      "language": "javascript",
      "code": "// Recreate the bike:1 key so this example runs on its own.\nawait client.set(\"bike:1\", \"Deimos\");\n\nconst res3 = await client.set(\"bike:1\", \"bike\", {'NX': true});\nconsole.log(res3);  // null\nconsole.log(await client.get(\"bike:1\"));  // Deimos\nconst res4 = await client.set(\"bike:1\", \"bike\", {'XX': true});\nconsole.log(res4);  // OK",
      "section_id": "string-command-summary"
    },
    {
      "id": "string-command-summary-ex19",
      "language": "php",
      "code": "// Recreate the bike:1 key so this example runs on its own.\n        $r->set('bike:1', 'Deimos');\n\n        $res3 = $r->set('bike:1', 'bike', 'nx');\n        echo var_export($res3, true) . PHP_EOL;\n        // >>> NULL\n        \n        echo $r->get('bike:1') . PHP_EOL;\n        // >>> Deimos\n\n        $res4 = $r->set('bike:1', 'bike', 'xx');\n        echo \"$res4\" . PHP_EOL;\n        // >>> OK",
      "section_id": "string-command-summary"
    },
    {
      "id": "string-command-summary-ex20",
      "language": "python",
      "code": "# Recreate the bike:1 key so this example runs on its own.\nr.set(\"bike:1\", \"Deimos\")\n\nres3 = r.set(\"bike:1\", \"bike\", nx=True)\nprint(res3)  # None\nprint(r.get(\"bike:1\"))  # Deimos\nres4 = r.set(\"bike:1\", \"bike\", xx=True)\nprint(res4)  # True",
      "section_id": "string-command-summary"
    },
    {
      "id": "string-command-summary-ex21",
      "language": "ruby",
      "code": "# Recreate the bike:1 key so this example runs on its own.\nr.set('bike:1', 'Deimos')\n\nres3 = r.set('bike:1', 'bike', nx: true)\nputs res3 # >>> false\n\nputs r.get('bike:1') # >>> Deimos\n\nres4 = r.set('bike:1', 'bike', xx: true)\nputs res4 # >>> true",
      "section_id": "string-command-summary"
    },
    {
      "id": "string-command-summary-ex22",
      "language": "rust",
      "code": "// Recreate the bike:1 key so this example runs on its own.\n        let _: () = r.set(\"bike:1\", \"Deimos\").await.expect(\"Failed to set\");\n\n        if let Ok(res) = r.set_options(\"bike:1\", \"bike\", redis::SetOptions::default().conditional_set(ExistenceCheck::NX)).await {\n            let res: bool = res;\n            println!(\"{res}\");    // >>> false\n        }\n\n        match r.get(\"bike:1\").await {\n            Ok(res) => {\n                let res: String = res;\n                println!(\"{res}\");   // >>> Deimos\n            },\n            Err(e) => {\n                println!(\"Error getting foo: {e}\");\n                return;\n            }\n        };\n\n        if let Ok(res) = r.set_options(\"bike:1\", \"bike\", redis::SetOptions::default().conditional_set(ExistenceCheck::XX)).await {\n            let res: String = res;\n            println!(\"{res}\");    // >>> OK\n        }\n\n        match r.get(\"bike:1\").await {\n            Ok(res) => {\n                let res: String = res;\n                println!(\"{res}\");   // >>> bike\n            },\n            Err(e) => {\n                println!(\"Error getting foo: {e}\");\n                return;\n            }\n        };",
      "section_id": "string-command-summary"
    },
    {
      "id": "string-command-summary-ex23",
      "language": "rust",
      "code": "// Recreate the bike:1 key so this example runs on its own.\n        let _: () = r.set(\"bike:1\", \"Deimos\").expect(\"Failed to set\");\n\n        if let Ok(res) = r.set_options(\"bike:1\", \"bike\", redis::SetOptions::default().conditional_set(ExistenceCheck::NX)) {\n            let res: bool = res;\n            println!(\"{res}\");    // >>> false\n        }\n\n        match r.get(\"bike:1\") {\n            Ok(res) => {\n                let res: String = res;\n                println!(\"{res}\");   // >>> Deimos\n            },\n            Err(e) => {\n                println!(\"Error getting bike:1: {e}\");\n                return;\n            }\n        };\n\n        if let Ok(res) = r.set_options(\"bike:1\", \"bike\", redis::SetOptions::default().conditional_set(ExistenceCheck::XX)) {\n            let res: String = res;\n            println!(\"{res}\");    // >>> OK\n        }\n        \n        match r.get(\"bike:1\") {\n            Ok(res) => {\n                let res: String = res;\n                println!(\"{res}\");   // >>> bike\n            },\n            Err(e) => {\n                println!(\"Error getting bike:1: {e}\");\n                return;\n            }\n        };",
      "section_id": "string-command-summary"
    },
    {
      "id": "string-command-summary-ex24",
      "language": "plaintext",
      "code": "> SET bike:1 Deimos\nOK\n> SET bike:1 Ares IFEQ Deimos\nOK\n> SET bike:1 Zeus IFEQ Deimos\n(nil)\n> GET bike:1\n\"Ares\"\n> DELEX bike:1 IFEQ Deimos\n(integer) 0\n> DELEX bike:1 IFEQ Ares\n(integer) 1",
      "section_id": "string-command-summary"
    },
    {
      "id": "string-command-summary-ex25",
      "language": "csharp",
      "code": "db.StringSet(\"bike:1\", \"Deimos\");\n\n        var res9 = db.StringSet(\"bike:1\", \"Ares\", when: ValueCondition.Equal(\"Deimos\"));\n        Console.WriteLine(res9); // True\n        var res10 = db.StringSet(\"bike:1\", \"Zeus\", when: ValueCondition.Equal(\"Deimos\"));\n        Console.WriteLine(res10); // False\n        Console.WriteLine(db.StringGet(\"bike:1\")); // Ares\n\n        var res11 = db.StringDelete(\"bike:1\", ValueCondition.Equal(\"Deimos\"));\n        Console.WriteLine(res11); // False\n        var res12 = db.StringDelete(\"bike:1\", ValueCondition.Equal(\"Ares\"));\n        Console.WriteLine(res12); // True",
      "section_id": "string-command-summary"
    },
    {
      "id": "string-command-summary-ex26",
      "language": "go",
      "code": "rdb.Set(ctx, \"bike:1\", \"Deimos\", 0)\n\n\tres11, err := rdb.SetIFEQ(ctx, \"bike:1\", \"Ares\", \"Deimos\", 0).Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(res11) // >>> OK\n\n\t// The value no longer matches, so SetIFEQ returns redis.Nil.\n\t_, err = rdb.SetIFEQ(ctx, \"bike:1\", \"Zeus\", \"Deimos\", 0).Result()\n\n\tif err != nil && err != redis.Nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(err == redis.Nil) // >>> true\n\n\tres12, err := rdb.Get(ctx, \"bike:1\").Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(res12) // >>> Ares\n\n\tres13, err := rdb.DelExArgs(ctx, \"bike:1\", redis.DelExArgs{\n\t\tMode: \"IFEQ\", MatchValue: \"Deimos\",\n\t}).Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(res13) // >>> 0\n\n\tres14, err := rdb.DelExArgs(ctx, \"bike:1\", redis.DelExArgs{\n\t\tMode: \"IFEQ\", MatchValue: \"Ares\",\n\t}).Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(res14) // >>> 1",
      "section_id": "string-command-summary"
    },
    {
      "id": "string-command-summary-ex27",
      "language": "java",
      "code": "CompletableFuture<Void> casCad = asyncCommands.set(\"bike:1\", \"Deimos\")\n                    .thenCompose(setup -> asyncCommands.set(\"bike:1\", \"Ares\",\n                            SetArgs.Builder.compareCondition(CompareCondition.valueEq(\"Deimos\"))))\n                    .thenCompose(v -> {\n                        System.out.println(v); // >>> OK\n                        return asyncCommands.set(\"bike:1\", \"Zeus\",\n                                SetArgs.Builder.compareCondition(CompareCondition.valueEq(\"Deimos\")));\n                    }).thenCompose(v -> {\n                        System.out.println(v); // >>> null\n                        return asyncCommands.get(\"bike:1\");\n                    }).thenCompose(v -> {\n                        System.out.println(v); // >>> Ares\n                        return asyncCommands.delex(\"bike:1\", CompareCondition.valueEq(\"Deimos\"));\n                    }).thenCompose(v -> {\n                        System.out.println(v); // >>> 0\n                        return asyncCommands.delex(\"bike:1\", CompareCondition.valueEq(\"Ares\"));\n                    })\n                    .thenAccept(System.out::println) // >>> 1\n                    .toCompletableFuture();",
      "section_id": "string-command-summary"
    },
    {
      "id": "string-command-summary-ex28",
      "language": "java",
      "code": "Mono<Void> casCad = reactiveCommands.set(\"bike:1\", \"Deimos\")\n                    .flatMap(setup -> reactiveCommands.set(\"bike:1\", \"Ares\",\n                            SetArgs.Builder.compareCondition(CompareCondition.valueEq(\"Deimos\"))))\n                    .doOnNext(res -> {\n                        System.out.println(res); // OK\n                    })\n                    // A failed condition returns an empty Mono, so check for an element.\n                    .flatMap(v -> reactiveCommands.set(\"bike:1\", \"Zeus\",\n                            SetArgs.Builder.compareCondition(CompareCondition.valueEq(\"Deimos\"))).hasElement())\n                    .doOnNext(res -> {\n                        System.out.println(res); // false\n                    }).flatMap(v -> reactiveCommands.get(\"bike:1\")).doOnNext(res -> {\n                        System.out.println(res); // Ares\n                    }).flatMap(v -> reactiveCommands.delex(\"bike:1\", CompareCondition.valueEq(\"Deimos\")))\n                    .doOnNext(res -> {\n                        System.out.println(res); // 0\n                    }).flatMap(v -> reactiveCommands.delex(\"bike:1\", CompareCondition.valueEq(\"Ares\")))\n                    .doOnNext(res -> {\n                        System.out.println(res); // 1\n                    }).then();",
      "section_id": "string-command-summary"
    },
    {
      "id": "string-command-summary-ex29",
      "language": "java",
      "code": "jedis.set(\"bike:1\", \"Deimos\");\n\n      String res9 = jedis.set(\"bike:1\", \"Ares\",\n          SetParams.setParams().condition(CompareCondition.valueEq(\"Deimos\")));\n      System.out.println(res9); // OK\n      String res10 = jedis.set(\"bike:1\", \"Zeus\",\n          SetParams.setParams().condition(CompareCondition.valueEq(\"Deimos\")));\n      System.out.println(res10); // null\n      System.out.println(jedis.get(\"bike:1\")); // Ares\n\n      long res11 = jedis.delex(\"bike:1\", CompareCondition.valueEq(\"Deimos\"));\n      System.out.println(res11); // 0\n      long res12 = jedis.delex(\"bike:1\", CompareCondition.valueEq(\"Ares\"));\n      System.out.println(res12); // 1",
      "section_id": "string-command-summary"
    },
    {
      "id": "string-command-summary-ex30",
      "language": "javascript",
      "code": "await client.set(\"bike:1\", \"Deimos\");\n\nconst res9 = await client.set(\"bike:1\", \"Ares\", {\n  condition: 'IFEQ', matchValue: \"Deimos\"\n});\nconsole.log(res9);  // OK\nconst res10 = await client.set(\"bike:1\", \"Zeus\", {\n  condition: 'IFEQ', matchValue: \"Deimos\"\n});\nconsole.log(res10);  // null\nconsole.log(await client.get(\"bike:1\"));  // Ares\n\nconst res11 = await client.delEx(\"bike:1\", {\n  condition: 'IFEQ', matchValue: \"Deimos\"\n});\nconsole.log(res11);  // 0\nconst res12 = await client.delEx(\"bike:1\", {\n  condition: 'IFEQ', matchValue: \"Ares\"\n});\nconsole.log(res12);  // 1",
      "section_id": "string-command-summary"
    },
    {
      "id": "string-command-summary-ex31",
      "language": "php",
      "code": "$r->set('bike:1', 'Deimos');\n\n        $res9 = $r->set('bike:1', 'Ares', null, null, 'IFEQ', 'Deimos');\n        echo \"$res9\" . PHP_EOL;\n        // >>> OK\n\n        $res10 = $r->set('bike:1', 'Zeus', null, null, 'IFEQ', 'Deimos');\n        echo var_export($res10, true) . PHP_EOL;\n        // >>> NULL\n\n        echo $r->get('bike:1') . PHP_EOL;\n        // >>> Ares\n\n        $res11 = $r->delex('bike:1', 'IFEQ', 'Deimos');\n        echo \"$res11\" . PHP_EOL;\n        // >>> 0\n\n        $res12 = $r->delex('bike:1', 'IFEQ', 'Ares');\n        echo \"$res12\" . PHP_EOL;\n        // >>> 1",
      "section_id": "string-command-summary"
    },
    {
      "id": "string-command-summary-ex32",
      "language": "python",
      "code": "r.set(\"bike:1\", \"Deimos\")\n\nres9 = r.set(\"bike:1\", \"Ares\", ifeq=\"Deimos\")\nprint(res9)  # True\nres10 = r.set(\"bike:1\", \"Zeus\", ifeq=\"Deimos\")\nprint(res10)  # None\nprint(r.get(\"bike:1\"))  # Ares\n\nres11 = r.delex(\"bike:1\", ifeq=\"Deimos\")\nprint(res11)  # 0\nres12 = r.delex(\"bike:1\", ifeq=\"Ares\")\nprint(res12)  # 1",
      "section_id": "string-command-summary"
    },
    {
      "id": "string-command-summary-ex33",
      "language": "rust",
      "code": "let _: () = r.set(\"bike:1\", \"Deimos\").await.expect(\"Failed to set\");\n\n        let res: Option<String> = r\n            .set_options(\"bike:1\", \"Ares\", redis::SetOptions::default().value_comparison(ValueComparison::ifeq(\"Deimos\")))\n            .await.expect(\"Failed to set\");\n        println!(\"{res:?}\");    // >>> Some(\"OK\")\n\n        let res: Option<String> = r\n            .set_options(\"bike:1\", \"Zeus\", redis::SetOptions::default().value_comparison(ValueComparison::ifeq(\"Deimos\")))\n            .await.expect(\"Failed to set\");\n        println!(\"{res:?}\");    // >>> None\n\n        let res: String = r.get(\"bike:1\").await.expect(\"Failed to get\");\n        println!(\"{res}\");   // >>> Ares\n\n        let res: usize = r.del_ex(\"bike:1\", ValueComparison::ifeq(\"Deimos\")).await.expect(\"Failed to delete\");\n        println!(\"{res}\");    // >>> 0\n\n        let res: usize = r.del_ex(\"bike:1\", ValueComparison::ifeq(\"Ares\")).await.expect(\"Failed to delete\");\n        println!(\"{res}\");    // >>> 1",
      "section_id": "string-command-summary"
    },
    {
      "id": "string-command-summary-ex34",
      "language": "rust",
      "code": "let _: () = r.set(\"bike:1\", \"Deimos\").expect(\"Failed to set\");\n\n        let res: Option<String> = r\n            .set_options(\"bike:1\", \"Ares\", redis::SetOptions::default().value_comparison(ValueComparison::ifeq(\"Deimos\")))\n            .expect(\"Failed to set\");\n        println!(\"{res:?}\");    // >>> Some(\"OK\")\n\n        let res: Option<String> = r\n            .set_options(\"bike:1\", \"Zeus\", redis::SetOptions::default().value_comparison(ValueComparison::ifeq(\"Deimos\")))\n            .expect(\"Failed to set\");\n        println!(\"{res:?}\");    // >>> None\n\n        let res: String = r.get(\"bike:1\").expect(\"Failed to get\");\n        println!(\"{res}\");   // >>> Ares\n\n        let res: usize = r.del_ex(\"bike:1\", ValueComparison::ifeq(\"Deimos\")).expect(\"Failed to delete\");\n        println!(\"{res}\");    // >>> 0\n\n        let res: usize = r.del_ex(\"bike:1\", ValueComparison::ifeq(\"Ares\")).expect(\"Failed to delete\");\n        println!(\"{res}\");    // >>> 1",
      "section_id": "string-command-summary"
    },
    {
      "id": "string-command-summary-ex35",
      "language": "plaintext",
      "code": "> MSET bike:1 \"Deimos\" bike:2 \"Ares\" bike:3 \"Vanth\"\nOK\n> MGET bike:1 bike:2 bike:3\n1) \"Deimos\"\n2) \"Ares\"\n3) \"Vanth\"",
      "section_id": "string-command-summary"
    },
    {
      "id": "string-command-summary-ex36",
      "language": "csharp",
      "code": "var res5 = db.StringSet([\n            new (\"bike:1\", \"Deimos\"), new(\"bike:2\", \"Ares\"), new(\"bike:3\", \"Vanth\")\n        ]);\n        Console.WriteLine(res5);\n        var res6 = db.StringGet([\"bike:1\", \"bike:2\", \"bike:3\"]);\n        Console.WriteLine(string.Join(\", \", res6));",
      "section_id": "string-command-summary"
    },
    {
      "id": "string-command-summary-ex37",
      "language": "go",
      "code": "res6, err := rdb.MSet(ctx, \"bike:1\", \"Deimos\", \"bike:2\", \"Ares\", \"bike:3\", \"Vanth\").Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(res6) // >>> OK\n\n\tres7, err := rdb.MGet(ctx, \"bike:1\", \"bike:2\", \"bike:3\").Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(res7) // >>> [Deimos Ares Vanth]",
      "section_id": "string-command-summary"
    },
    {
      "id": "string-command-summary-ex38",
      "language": "java",
      "code": "Map<String, String> bikeMap = new HashMap<>();\n            bikeMap.put(\"bike:1\", \"Deimos\");\n            bikeMap.put(\"bike:2\", \"Ares\");\n            bikeMap.put(\"bike:3\", \"Vanth\");\n\n            CompletableFuture<Void> mset = asyncCommands.mset(bikeMap).thenCompose(v -> {\n                System.out.println(v); // >>> OK\n                return asyncCommands.mget(\"bike:1\", \"bike:2\", \"bike:3\");\n            })\n                    .thenAccept(System.out::println)\n                    // >>> [KeyValue[bike:1, Deimos], KeyValue[bike:2, Ares], KeyValue[bike:3,\n                    // Vanth]]\n                    .toCompletableFuture();",
      "section_id": "string-command-summary"
    },
    {
      "id": "string-command-summary-ex39",
      "language": "java",
      "code": "Map<String, String> bikeMap = new HashMap<>();\n            bikeMap.put(\"bike:1\", \"Deimos\");\n            bikeMap.put(\"bike:2\", \"Ares\");\n            bikeMap.put(\"bike:3\", \"Vanth\");\n\n            Mono<Void> mset = reactiveCommands.mset(bikeMap).doOnNext(System.out::println) // OK\n                    .flatMap(v -> reactiveCommands.mget(\"bike:1\", \"bike:2\", \"bike:3\").collectList()).doOnNext(res -> {\n                        System.out.println(res); // [KeyValue[bike:1, Deimos], KeyValue[bike:2, Ares], KeyValue[bike:3, Vanth]]\n                    }).then();",
      "section_id": "string-command-summary"
    },
    {
      "id": "string-command-summary-ex40",
      "language": "java",
      "code": "String res5 = jedis.mset(\"bike:1\", \"Deimos\", \"bike:2\", \"Ares\", \"bike:3\", \"Vanth\");\n      System.out.println(res5); // OK\n      List<String> res6 = jedis.mget(\"bike:1\", \"bike:2\", \"bike:3\");\n      System.out.println(res6); // [Deimos, Ares, Vanth]",
      "section_id": "string-command-summary"
    },
    {
      "id": "string-command-summary-ex41",
      "language": "javascript",
      "code": "const res5 = await client.mSet([\n  [\"bike:1\", \"Deimos\"],\n  [\"bike:2\", \"Ares\"],\n  [\"bike:3\", \"Vanth\"]\n]);\n\nconsole.log(res5);  // OK\nconst res6 = await client.mGet([\"bike:1\", \"bike:2\", \"bike:3\"]);\nconsole.log(res6);  // ['Deimos', 'Ares', 'Vanth']",
      "section_id": "string-command-summary"
    },
    {
      "id": "string-command-summary-ex42",
      "language": "php",
      "code": "$res5 = $r->mset([\n            'bike:1' => 'Deimos', 'bike:2' => 'Ares', 'bike:3' => 'Vanth'\n        ]);\n        echo \"$res5\" . PHP_EOL;\n        // >>> OK\n\n        $res6 = $r->mget(['bike:1', 'bike:2', 'bike:3']);\n        echo json_encode($res6) . PHP_EOL;\n        // >>> [\"Deimos\",\"Ares\",\"Vanth\"]",
      "section_id": "string-command-summary"
    },
    {
      "id": "string-command-summary-ex43",
      "language": "python",
      "code": "res5 = r.mset({\"bike:1\": \"Deimos\", \"bike:2\": \"Ares\", \"bike:3\": \"Vanth\"})\nprint(res5)  # True\nres6 = r.mget([\"bike:1\", \"bike:2\", \"bike:3\"])\nprint(res6)  # ['Deimos', 'Ares', 'Vanth']",
      "section_id": "string-command-summary"
    },
    {
      "id": "string-command-summary-ex44",
      "language": "ruby",
      "code": "res5 = r.mset('bike:1', 'Deimos', 'bike:2', 'Ares', 'bike:3', 'Vanth')\nputs res5 # >>> OK\n\nres6 = r.mget('bike:1', 'bike:2', 'bike:3')\nputs res6.inspect # >>> [\"Deimos\", \"Ares\", \"Vanth\"]",
      "section_id": "string-command-summary"
    },
    {
      "id": "string-command-summary-ex45",
      "language": "rust",
      "code": "if let Ok(res) = r.mset(&[(\"bike:1\", \"Deimos\"), (\"bike:2\", \"Ares\"), (\"bike:3\", \"Vanth\")]).await {\n            let res: String = res;\n            println!(\"{res}\");    // >>> OK\n        }\n\n        match r.mget(&[\"bike:1\", \"bike:2\", \"bike:3\"]).await {\n            Ok(res) => {\n                let res: Vec<String> = res;\n                println!(\"{res:?}\");   // >>> [\"Deimos\", \"Ares\", \"Vanth\"]\n            },\n            Err(e) => {\n                println!(\"Error getting foo: {e}\");\n                return;\n            }\n        };",
      "section_id": "string-command-summary"
    },
    {
      "id": "string-command-summary-ex46",
      "language": "rust",
      "code": "if let Ok(res) = r.mset(&[(\"bike:1\", \"Deimos\"), (\"bike:2\", \"Ares\"), (\"bike:3\", \"Vanth\")]) {\n            let res: String = res;\n            println!(\"{res}\");    // >>> OK\n        }\n\n        match r.mget(&[\"bike:1\", \"bike:2\", \"bike:3\"]) {\n            Ok(res) => {\n                let res: Vec<String> = res;\n                println!(\"{res:?}\");   // >>> [\"Deimos\", \"Ares\", \"Vanth\"]\n            },\n            Err(e) => {\n                println!(\"Error getting values: {e}\");\n                return;\n            }\n        };",
      "section_id": "string-command-summary"
    },
    {
      "id": "strings-as-counters-ex0",
      "language": "plaintext",
      "code": "> SET total_crashes 0\nOK\n> INCR total_crashes\n(integer) 1\n> INCRBY total_crashes 10\n(integer) 11",
      "section_id": "strings-as-counters"
    },
    {
      "id": "strings-as-counters-ex1",
      "language": "csharp",
      "code": "db.StringSet(\"total_crashes\", 0);\n        var res7 = db.StringIncrement(\"total_crashes\");\n        Console.WriteLine(res7); // 1\n        var res8 = db.StringIncrement(\"total_crashes\", 10);\n        Console.WriteLine(res8);",
      "section_id": "strings-as-counters"
    },
    {
      "id": "strings-as-counters-ex2",
      "language": "go",
      "code": "res8, err := rdb.Set(ctx, \"total_crashes\", \"0\", 0).Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(res8) // >>> OK\n\n\tres9, err := rdb.Incr(ctx, \"total_crashes\").Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(res9) // >>> 1\n\n\tres10, err := rdb.IncrBy(ctx, \"total_crashes\", 10).Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(res10) // >>> 11",
      "section_id": "strings-as-counters"
    },
    {
      "id": "strings-as-counters-ex3",
      "language": "java",
      "code": "CompletableFuture<Void> incrby = asyncCommands.set(\"total_crashes\", \"0\")\n                    .thenCompose(v -> asyncCommands.incr(\"total_crashes\")).thenCompose(v -> {\n                        System.out.println(v); // >>> 1\n                        return asyncCommands.incrby(\"total_crashes\", 10);\n                    })\n                    .thenAccept(System.out::println) // >>> 11\n                    .toCompletableFuture();",
      "section_id": "strings-as-counters"
    },
    {
      "id": "strings-as-counters-ex4",
      "language": "java",
      "code": "Mono<Void> incrby = reactiveCommands.set(\"total_crashes\", \"0\").flatMap(v -> reactiveCommands.incr(\"total_crashes\"))\n                    .doOnNext(v -> {\n                        System.out.println(v); // 1\n                    }).flatMap(v -> reactiveCommands.incrby(\"total_crashes\", 10)).doOnNext(res -> {\n                        System.out.println(res); // 11\n                    }).then();",
      "section_id": "strings-as-counters"
    },
    {
      "id": "strings-as-counters-ex5",
      "language": "java",
      "code": "jedis.set(\"total_crashes\", \"0\");\n      Long res7 = jedis.incr(\"total_crashes\");\n      System.out.println(res7); // 1\n      Long res8 = jedis.incrBy(\"total_crashes\", 10);\n      System.out.println(res8); // 11",
      "section_id": "strings-as-counters"
    },
    {
      "id": "strings-as-counters-ex6",
      "language": "javascript",
      "code": "await client.set(\"total_crashes\", 0);\nconst res7 = await client.incr(\"total_crashes\");\nconsole.log(res7); // 1\nconst res8 = await client.incrBy(\"total_crashes\", 10);\nconsole.log(res8); // 11",
      "section_id": "strings-as-counters"
    },
    {
      "id": "strings-as-counters-ex7",
      "language": "php",
      "code": "$r->set('total_crashes', 0);\n        $res7 = $r->incr('total_crashes');\n        echo \"$res7\" . PHP_EOL;\n        // >>> 1\n\n        $res8 = $r->incrby('total_crashes', 10);\n        echo \"$res8\" . PHP_EOL;\n        // >>> 11",
      "section_id": "strings-as-counters"
    },
    {
      "id": "strings-as-counters-ex8",
      "language": "python",
      "code": "r.set(\"total_crashes\", 0)\nres7 = r.incr(\"total_crashes\")\nprint(res7)  # 1\nres8 = r.incrby(\"total_crashes\", 10)\nprint(res8)  # 11",
      "section_id": "strings-as-counters"
    },
    {
      "id": "strings-as-counters-ex9",
      "language": "ruby",
      "code": "r.set('total_crashes', 0)\n\nres7 = r.incr('total_crashes')\nputs res7 # >>> 1\n\nres8 = r.incrby('total_crashes', 10)\nputs res8 # >>> 11",
      "section_id": "strings-as-counters"
    },
    {
      "id": "strings-as-counters-ex10",
      "language": "rust",
      "code": "if let Ok(res) = r.set(\"total_crashes\", 0).await {\n            let res: String = res;\n            println!(\"{res}\");    // >>> OK\n        }\n\n        if let Ok(res) = r.incr(\"total_crashes\", 1).await {\n            let res: i32 = res;\n            println!(\"{res}\");    // >>> 1\n        }\n\n        if let Ok(res) = r.incr(\"total_crashes\", 10).await {\n            let res: i32 = res;\n            println!(\"{res}\");    // >>> 11\n        }",
      "section_id": "strings-as-counters"
    },
    {
      "id": "strings-as-counters-ex11",
      "language": "rust",
      "code": "if let Ok(res) = r.set(\"total_crashes\", 0) {\n            let res: String = res;\n            println!(\"{res}\");    // >>> OK\n        }\n\n        if let Ok(res) = r.incr(\"total_crashes\", 1) {\n            let res: i32 = res;\n            println!(\"{res}\");    // >>> 1\n        }\n\n        if let Ok(res) = r.incr(\"total_crashes\", 10) {\n            let res: i32 = res;\n            println!(\"{res}\");    // >>> 11\n        }",
      "section_id": "strings-as-counters"
    }
  ]
}
