{
  "schema_version": 2,
  "id": "develop/data-types/lists",
  "title": "Redis lists",
  "url": "https://redis.io/docs/latest/develop/data-types/lists/",
  "summary": "Introduction to Redis lists",
  "aliases": [
    "/data-types/lists/",
    "/manual/data-types/lists/",
    "/develop/data-types/list/"
  ],
  "tags": [
    "docs",
    "develop",
    "stack",
    "oss",
    "rs",
    "rc",
    "oss",
    "kubernetes",
    "clients"
  ],
  "last_updated": "2026-09-10T15:45:53+01:00",
  "page_type": "content",
  "content_hash": "02d3f8dbe371261e31635931e55b202d6caa4dfcfd1a6ac300755613e3eae1fb",
  "sections": [
    {
      "id": "list-command-summary",
      "title": "List command summary",
      "role": "content",
      "text": "**24 commands in this group:**\n\n[View all list commands](https://redis.io/commands/?group=list)\n\n| Command | Summary | Complexity | Since |\n|---------|---------|------------|-------|\n| [BLMOVE](https://redis.io/commands/blmove/) | Pops an element from a list, pushes it to another list and returns it. Blocks until an element is available otherwise. Deletes the list if the last element was moved. | O(1) | 6.2.0 |\n| [BLMOVEM](https://redis.io/commands/blmovem/) | Moves up to (or exactly) a number of elements from one list to another and returns them. Blocks until the elements are available otherwise. Deletes the source list if it becomes empty. | O(N) where N is the number of elements moved. | 8.10.0 |\n| [BLMPOP](https://redis.io/commands/blmpop/) | Pops the first element from one of multiple lists. Blocks until an element is available otherwise. Deletes the list if the last element was popped. | O(N+M) where N is the number of provided keys a... | 7.0.0 |\n| [BLPOP](https://redis.io/commands/blpop/) | Removes and returns the first element in a list. Blocks until an element is available otherwise. Deletes the list if the last element was popped. | O(N) where N is the number of provided keys. | 2.0.0 |\n| [BRPOP](https://redis.io/commands/brpop/) | Removes and returns the last element in a list. Blocks until an element is available otherwise. Deletes the list if the last element was popped. | O(N) where N is the number of provided keys. | 2.0.0 |\n| [BRPOPLPUSH](https://redis.io/commands/brpoplpush/) | Pops an element from a list, pushes it to another list and returns it. Block until an element is available otherwise. Deletes the list if the last element was popped. | O(1) | 2.2.0 |\n| [LINDEX](https://redis.io/commands/lindex/) | Returns an element from a list by its index. | O(N) where N is the number of elements to trave... | 1.0.0 |\n| [LINSERT](https://redis.io/commands/linsert/) | Inserts an element before or after another element in a list. | O(N) where N is the number of elements to trave... | 2.2.0 |\n| [LLEN](https://redis.io/commands/llen/) | Returns the length of a list. | O(1) | 1.0.0 |\n| [LMOVE](https://redis.io/commands/lmove/) | Returns an element after popping it from one list and pushing it to another. Deletes the list if the last element was moved. | O(1) | 6.2.0 |\n\n#### List command summary (part 2)\n\n| Command | Summary | Complexity | Since |\n|---------|---------|------------|-------|\n| [LMOVEM](https://redis.io/commands/lmovem/) | Moves up to (or exactly) a number of elements from one list to another and returns them. Deletes the source list if it becomes empty. | O(N) where N is the number of elements moved. | 8.10.0 |\n| [LMPOP](https://redis.io/commands/lmpop/) | Returns multiple elements from a list after removing them. Deletes the list if the last element was popped. | O(N+M) where N is the number of provided keys a... | 7.0.0 |\n| [LPOP](https://redis.io/commands/lpop/) | Returns the first elements in a list after removing it. Deletes the list if the last element was popped. | O(N) where N is the number of elements returned | 1.0.0 |\n| [LPOS](https://redis.io/commands/lpos/) | Returns the index of matching elements in a list. | O(N) where N is the number of elements in the l... | 6.0.6 |\n| [LPUSH](https://redis.io/commands/lpush/) | Prepends one or more elements to a list. Creates the key if it doesn't exist. | O(1) for each element added, so O(N) to add N e... | 1.0.0 |\n| [LPUSHX](https://redis.io/commands/lpushx/) | Prepends one or more elements to a list only when the list exists. | O(1) for each element added, so O(N) to add N e... | 2.2.0 |\n| [LRANGE](https://redis.io/commands/lrange/) | Returns a range of elements from a list. | O(S+N) where S is the distance of start offset ... | 1.0.0 |\n| [LREM](https://redis.io/commands/lrem/) | Removes elements from a list. Deletes the list if the last element was removed. | O(N+M) where N is the length of the list and M ... | 1.0.0 |\n| [LSET](https://redis.io/commands/lset/) | Sets the value of an element in a list by its index. | O(N) where N is the length of the list. Setting... | 1.0.0 |\n| [LTRIM](https://redis.io/commands/ltrim/) | Removes elements from both ends a list. Deletes the list if all elements were trimmed. | O(N) where N is the number of elements to be re... | 1.0.0 |\n\n#### List command summary (part 3)\n\n| Command | Summary | Complexity | Since |\n|---------|---------|------------|-------|\n| [RPOP](https://redis.io/commands/rpop/) | Returns and removes the last elements of a list. Deletes the list if the last element was popped. | O(N) where N is the number of elements returned | 1.0.0 |\n| [RPOPLPUSH](https://redis.io/commands/rpoplpush/) | Returns the last element of a list after removing and pushing it to another list. Deletes the list if the last element was popped. | O(1) | 1.2.0 |\n| [RPUSH](https://redis.io/commands/rpush/) | Appends one or more elements to a list. Creates the key if it doesn't exist. | O(1) for each element added, so O(N) to add N e... | 1.0.0 |\n| [RPUSHX](https://redis.io/commands/rpushx/) | Appends an element to a list only when the list exists. | O(1) for each element added, so O(N) to add N e... | 2.2.0 |\n\n\n\nRedis lists are linked lists of string values.\nRedis lists are frequently used to:\n\n* Implement stacks and queues.\n* Build queue management for background worker systems."
    },
    {
      "id": "examples",
      "title": "Examples",
      "role": "example",
      "text": "* Treat a list like a queue (first in, first out):\nQueue pattern: Use LPUSH to add items and RPOP to remove them in FIFO order when you need to process items in the order they were added\n\n**Builds upon:** lpush_rpush, lpop_rpop\n\n**Commands:** LPUSH, RPOP\n\n**Complexity:**\n- LPUSH: O(1)\n- RPOP: O(N)\n\n**Available in:** Redis CLI, C#, C#, Go, Java (Asynchronous - 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##### C#\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 (Asynchronous - 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\n* Treat a list like a stack (first in, last out):\nStack pattern: Use LPUSH to add items and LPOP to remove them in LIFO order when you need to process items in reverse order\n\n**Builds upon:** lpush_rpush\n\n**Commands:** LPUSH, LPOP\n\n**Complexity:**\n- LPUSH: O(1)\n- LPOP: O(N)\n\n**Available in:** Redis CLI, C#, C#, Go, Java (Asynchronous - 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##### C#\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 (Asynchronous - 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\n* Check the length of a list:\nFoundational: Get the number of elements in a list using LLEN to check list size\n\n**Commands:** LLEN\n\n**Complexity:**\n- LLEN: O(1)\n\n**Available in:** Redis CLI, C#, C#, Go, Java (Asynchronous - 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##### C#\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 (Asynchronous - 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\n* Atomically pop an element from one list and push to another:\nAtomic transfer: Use LMOVE to move elements between lists in a single operation when you need to transfer items without race conditions\n\n**Difficulty:** Intermediate\n\n**Builds upon:** lpush_rpush, lpop_rpop\n\n**Commands:** LPUSH, LMOVE, LRANGE\n\n**Complexity:**\n- LPUSH: O(1)\n- LMOVE: O(1)\n- LRANGE: O(S+N)\n\n**Available in:** Redis CLI, C#, C#, Go, Java (Asynchronous - 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##### C#\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 (Asynchronous - 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\n* To limit the length of a list you can call [`LTRIM`](https://redis.io/docs/latest/commands/ltrim):\nCapped lists: Use LTRIM to keep only a specific range of elements when you need to maintain a fixed-size list\n\n**Difficulty:** Intermediate\n\n**Builds upon:** lpush_rpush\n\n**Commands:** DEL, RPUSH, LTRIM, LRANGE\n\n**Complexity:**\n- DEL: O(N)\n- RPUSH: O(1)\n- LTRIM: O(N)\n- LRANGE: O(S+N)\n\n**Available in:** Redis CLI, C#, C#, Go, Java (Asynchronous - 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##### C#\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 (Asynchronous - 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]"
    },
    {
      "id": "what-are-lists",
      "title": "What are Lists?",
      "role": "content",
      "text": "To explain the List data type it's better to start with a little bit of theory,\nas the term *List* is often used in an improper way by information technology\nfolks. For instance \"Python Lists\" are not what the name may suggest (Linked\nLists), but rather Arrays (the same data type is called Array in\nRuby actually).\n\nFrom a very general point of view a List is just a sequence of ordered\nelements: 10,20,1,2,3 is a list. But the properties of a List implemented using\nan Array are very different from the properties of a List implemented using a\n*Linked List*.\n\nRedis lists are implemented via Linked Lists. This means that even if you have\nmillions of elements inside a list, the operation of adding a new element in\nthe head or in the tail of the list is performed *in constant time*. The speed of adding a\nnew element with the [`LPUSH`](https://redis.io/docs/latest/commands/lpush) command to the head of a list with ten\nelements is the same as adding an element to the head of list with 10\nmillion elements.\n\nWhat's the downside? Accessing an element *by index* is very fast in lists\nimplemented with an Array (constant time indexed access) and not so fast in\nlists implemented by linked lists (where the operation requires an amount of\nwork proportional to the index of the accessed element).\n\nRedis Lists are implemented with linked lists because for a database system it\nis crucial to be able to add elements to a very long list in a very fast way.\nAnother strong advantage, as you'll see in a moment, is that Redis Lists can be\ntaken at constant length in constant time.\n\nWhen fast access to the middle of a large collection of elements is important,\nthere is a different data structure that can be used, called sorted sets.\nSorted sets are covered in the [Sorted sets](https://redis.io/docs/latest/develop/data-types/sorted-sets) tutorial page."
    },
    {
      "id": "first-steps-with-redis-lists",
      "title": "First steps with Redis Lists",
      "role": "content",
      "text": "The [`LPUSH`](https://redis.io/docs/latest/commands/lpush) command adds a new element into a list, on the\nleft (at the head), while the [`RPUSH`](https://redis.io/docs/latest/commands/rpush) command adds a new\nelement into a list, on the right (at the tail). Finally the\n[`LRANGE`](https://redis.io/docs/latest/commands/lrange) command extracts ranges of elements from lists:\n\nFoundational: Add elements to both ends of a list using LPUSH (left/head) and RPUSH (right/tail) to build ordered sequences\n\n**Commands:** DEL, RPUSH, LPUSH, LRANGE\n\n**Complexity:**\n- DEL: O(N)\n- RPUSH: O(1)\n- LPUSH: O(1)\n- LRANGE: O(S+N)\n\n**Available in:** Redis CLI, C#, C#, Go, Java (Asynchronous - 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##### C#\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 (Asynchronous - 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\nNote that [`LRANGE`](https://redis.io/docs/latest/commands/lrange) takes two indexes, the first and the last\nelement of the range to return. Both the indexes can be negative, telling Redis\nto start counting from the end: so -1 is the last element, -2 is the\npenultimate element of the list, and so forth.\n\nAs you can see [`RPUSH`](https://redis.io/docs/latest/commands/rpush) appended the elements on the right of the list, while\nthe final [`LPUSH`](https://redis.io/docs/latest/commands/lpush) appended the element on the left.\n\nBoth commands are *variadic commands*, meaning that you are free to push\nmultiple elements into a list in a single call:\n\nVariadic operations: Add multiple elements in a single command using LPUSH or RPUSH when you need to reduce round trips to the server\n\n**Builds upon:** lpush_rpush\n\n**Commands:** DEL, RPUSH, LPUSH, LRANGE\n\n**Complexity:**\n- DEL: O(N)\n- RPUSH: O(1)\n- LPUSH: O(1)\n- LRANGE: O(S+N)\n\n**Available in:** Redis CLI, C#, C#, Go, Java (Asynchronous - 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##### C#\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 (Asynchronous - 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\nAn important operation defined on Redis lists is the ability to *pop elements*.\nPopping elements is the operation of both retrieving the element from the list,\nand eliminating it from the list, at the same time. You can pop elements\nfrom left and right, similarly to how you can push elements in both sides\nof the list. We'll add three elements and pop three elements, so at the end of this\nsequence of commands the list is empty and there are no more elements to\npop:\n\nFoundational: Remove and retrieve elements from both ends of a list using LPOP (left/head) and RPOP (right/tail) to consume items\n\n**Commands:** DEL, RPUSH, RPOP, LPOP\n\n**Complexity:**\n- DEL: O(N)\n- RPUSH: O(1)\n- RPOP: O(N)\n- LPOP: O(N)\n\n**Available in:** Redis CLI, C#, C#, Go, Java (Asynchronous - 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##### C#\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 (Asynchronous - 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\nRedis returned a NULL value to signal that there are no elements in the\nlist."
    },
    {
      "id": "common-use-cases-for-lists",
      "title": "Common use cases for lists",
      "role": "content",
      "text": "Lists are useful for a number of tasks, two very representative use cases\nare the following:\n\n* Remember the latest updates posted by users into a social network.\n* Communication between processes, using a consumer-producer pattern where the producer pushes items into a list, and a consumer (usually a *worker*) consumes those items and executes actions. Redis has special list commands to make this use case both more reliable and efficient.\n\nFor example both the popular Ruby libraries [resque](https://github.com/resque/resque) and\n[sidekiq](https://github.com/mperham/sidekiq) use Redis lists under the hood in order to\nimplement background jobs.\n\nThe popular Twitter social network [takes the latest tweets](http://www.infoq.com/presentations/Real-Time-Delivery-Twitter)\nposted by users into Redis lists.\n\nTo describe a common use case step by step, imagine your home page shows the latest\nphotos published in a photo sharing social network and you want to speedup access.\n\n* Every time a user posts a new photo, we add its ID into a list with [`LPUSH`](https://redis.io/docs/latest/commands/lpush).\n* When users visit the home page, we use `LRANGE 0 9` in order to get the latest 10 posted items."
    },
    {
      "id": "capped-lists",
      "title": "Capped lists",
      "role": "content",
      "text": "In many use cases we just want to use lists to store the *latest items*,\nwhatever they are: social network updates, logs, or anything else.\n\nRedis allows us to use lists as a capped collection, only remembering the latest\nN items and discarding all the oldest items using the [`LTRIM`](https://redis.io/docs/latest/commands/ltrim) command.\n\nThe [`LTRIM`](https://redis.io/docs/latest/commands/ltrim) command is similar to [`LRANGE`](https://redis.io/docs/latest/commands/lrange), but **instead of displaying the\nspecified range of elements** it sets this range as the new list value. All\nthe elements outside the given range are removed.\n\nFor example, if you're adding bikes on the end of a list of repairs, but only\nwant to worry about the 3 that have been on the list the longest:\n\nCapped lists: Use LTRIM with positive indexes to keep a range of elements from the beginning when you need to maintain a fixed-size list\n\n**Difficulty:** Intermediate\n\n**Builds upon:** lpush_rpush\n\n**Commands:** DEL, RPUSH, LTRIM, LRANGE\n\n**Complexity:**\n- DEL: O(N)\n- RPUSH: O(1)\n- LTRIM: O(N)\n- LRANGE: O(S+N)\n\n**Available in:** Redis CLI, C#, C#, Go, Java (Asynchronous - 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##### C#\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 (Asynchronous - 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 above [`LTRIM`](https://redis.io/docs/latest/commands/ltrim) command tells Redis to keep just list elements from index\n0 to 2, everything else will be discarded. This allows for a very simple but\nuseful pattern: doing a List push operation + a List trim operation together \nto add a new element and discard elements exceeding a limit. Using \n[`LTRIM`](https://redis.io/docs/latest/commands/ltrim) with negative indexes can then be used to keep only the 3 most recently added:\n\nCapped lists with negative indexes: Use LTRIM with negative indexes to keep the most recent elements when you need to maintain a fixed-size list of latest items\n\n**Difficulty:** Intermediate\n\n**Builds upon:** lpush_rpush\n\n**Commands:** DEL, RPUSH, LTRIM, LRANGE\n\n**Complexity:**\n- DEL: O(N)\n- RPUSH: O(1)\n- LTRIM: O(N)\n- LRANGE: O(S+N)\n\n**Available in:** Redis CLI, C#, C#, Go, Java (Asynchronous - 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##### C#\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 (Asynchronous - 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 above combination adds new elements and keeps only the 3\nnewest elements into the list. With [`LRANGE`](https://redis.io/docs/latest/commands/lrange) you can access the top items\nwithout any need to remember very old data.\n\nNote: while [`LRANGE`](https://redis.io/docs/latest/commands/lrange) is technically an O(N) command, accessing small ranges\ntowards the head or the tail of the list is a constant time operation."
    },
    {
      "id": "blocking-operations-on-lists",
      "title": "Blocking operations on lists",
      "role": "content",
      "text": "Lists have a special feature that make them suitable to implement queues,\nand in general as a building block for inter process communication systems:\nblocking operations.\n\nImagine you want to push items into a list with one process, and use\na different process in order to actually do some kind of work with those\nitems. This is the usual producer / consumer setup, and can be implemented\nin the following simple way:\n\n* To push items into the list, producers call [`LPUSH`](https://redis.io/docs/latest/commands/lpush).\n* To extract / process items from the list, consumers call [`RPOP`](https://redis.io/docs/latest/commands/rpop).\n\nHowever it is possible that sometimes the list is empty and there is nothing\nto process, so [`RPOP`](https://redis.io/docs/latest/commands/rpop) just returns NULL. In this case a consumer is forced to wait\nsome time and retry again with [`RPOP`](https://redis.io/docs/latest/commands/rpop). This is called *polling*, and is not\na good idea in this context because it has several drawbacks:\n\n1. Forces Redis and clients to process useless commands (all the requests when the list is empty will get no actual work done, they'll just return NULL).\n2. Adds a delay to the processing of items, since after a worker receives a NULL, it waits some time. To make the delay smaller, we could wait less between calls to [`RPOP`](https://redis.io/docs/latest/commands/rpop), with the effect of amplifying problem number 1, i.e. more useless calls to Redis.\n\nSo Redis implements commands called [`BRPOP`](https://redis.io/docs/latest/commands/brpop) and [`BLPOP`](https://redis.io/docs/latest/commands/blpop) which are versions\nof [`RPOP`](https://redis.io/docs/latest/commands/rpop) and [`LPOP`](https://redis.io/docs/latest/commands/lpop) able to block if the list is empty: they'll return to\nthe caller only when a new element is added to the list, or when a user-specified\ntimeout is reached.\n\nThis is an example of a [`BRPOP`](https://redis.io/docs/latest/commands/brpop) call we could use in the worker:\n\nBlocking operations: Use BRPOP to wait for elements with a timeout when you need to implement producer-consumer patterns without polling\n\n**Difficulty:** Intermediate\n\n**Builds upon:** lpush_rpush, lpop_rpop\n\n**Commands:** DEL, RPUSH, BRPOP\n\n**Complexity:**\n- DEL: O(N)\n- RPUSH: O(1)\n- BRPOP: O(N)\n\n**Available in:** Redis CLI, C#, C#, Go, Java (Asynchronous - 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##### C#\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 (Asynchronous - 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\nIt means: \"wait for elements in the list `bikes:repairs`, but return if after 1 second\nno element is available\".\n\nNote that you can use 0 as timeout to wait for elements forever, and you can\nalso specify multiple lists and not just one, in order to wait on multiple\nlists at the same time, and get notified when the first list receives an\nelement.\n\nA few things to note about [`BRPOP`](https://redis.io/docs/latest/commands/brpop):\n\n1. Clients are served in an ordered way: the first client that blocked waiting for a list, is served first when an element is pushed by some other client, and so forth.\n2. The return value is different compared to [`RPOP`](https://redis.io/docs/latest/commands/rpop): it is a two-element array since it also includes the name of the key, because [`BRPOP`](https://redis.io/docs/latest/commands/brpop) and [`BLPOP`](https://redis.io/docs/latest/commands/blpop) are able to block waiting for elements from multiple lists.\n3. If the timeout is reached, NULL is returned.\n\nThere are more things you should know about lists and blocking ops. We\nsuggest that you read more on the following:\n\n* It is possible to build safer queues or rotating queues using [`LMOVE`](https://redis.io/docs/latest/commands/lmove).\n* There is also a blocking variant of the command, called [`BLMOVE`](https://redis.io/docs/latest/commands/blmove)."
    },
    {
      "id": "automatic-creation-and-removal-of-keys",
      "title": "Automatic creation and removal of keys",
      "role": "content",
      "text": "So far in our examples we never had to create empty lists before pushing\nelements, or removing empty lists when they no longer have elements inside.\nIt is Redis' responsibility to delete keys when lists are left empty, or to create\nan empty list if the key does not exist and we are trying to add elements\nto it, for example, with [`LPUSH`](https://redis.io/docs/latest/commands/lpush).\n\nThis is not specific to lists, it applies to all the Redis data types\ncomposed of multiple elements -- Streams, Sets, Sorted Sets and Hashes.\n\nBasically we can summarize the behavior with three rules:\n\n1. When we add an element to an aggregate data type, if the target key does not exist, an empty aggregate data type is created before adding the element.\n2. When we remove elements from an aggregate data type, if the value remains empty, the key is automatically destroyed. The Stream data type is the only exception to this rule.\n3. Calling a read-only command such as [`LLEN`](https://redis.io/docs/latest/commands/llen) (which returns the length of the list), or a write command removing elements, with an empty key, always produces the same result as if the key is holding an empty aggregate type of the type the command expects to find.\n\nExamples of rule 1:\n\nAutomatic creation: Redis automatically creates a list when you push to a non-existent key, simplifying initialization\n\n**Commands:** DEL, LPUSH\n\n**Complexity:**\n- DEL: O(N)\n- LPUSH: O(1)\n\n**Available in:** Redis CLI, C#, C#, Go, Java (Asynchronous - 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##### C#\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 (Asynchronous - 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\nHowever we can't perform operations against the wrong type if the key exists:\n\nType safety: Redis prevents operations on wrong data types, returning WRONGTYPE error when you try to use list commands on non-list keys\n\n**Builds upon:** rule_1\n\n**Commands:** DEL, SET, TYPE, LPUSH\n\n**Complexity:**\n- DEL: O(N)\n- SET: O(1)\n- TYPE: O(1)\n- LPUSH: O(1)\n\n**Available in:** Redis CLI, C#, C#, Go, Java (Asynchronous - 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##### C#\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 (Asynchronous - 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\nExample of rule 2:\n\nAutomatic removal: Redis automatically deletes empty lists, freeing memory when the last element is removed\n\n**Builds upon:** lpush_rpush, lpop_rpop\n\n**Commands:** DEL, LPUSH, EXISTS, LPOP\n\n**Complexity:**\n- DEL: O(N)\n- LPUSH: O(1)\n- EXISTS: O(N)\n- LPOP: O(N)\n\n**Available in:** Redis CLI, C#, C#, Go, Java (Asynchronous - 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##### C#\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 (Asynchronous - 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 key no longer exists after all the elements are popped.\n\nExample of rule 3:\n\nNil handling: Read-only commands on non-existent keys return empty results (0 or nil) instead of errors, treating them as empty lists\n\n**Commands:** DEL, LLEN, LPOP\n\n**Complexity:**\n- DEL: O(N)\n- LLEN: O(1)\n- LPOP: O(N)\n\n**Available in:** Redis CLI, C#, C#, Go, Java (Asynchronous - 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##### C#\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 (Asynchronous - 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]"
    },
    {
      "id": "limits",
      "title": "Limits",
      "role": "limits",
      "text": "The maximum length of a Redis list is 2^32 - 1 (4,294,967,295) elements."
    },
    {
      "id": "performance",
      "title": "Performance",
      "role": "performance",
      "text": "List operations that access its head or tail are O(1), which means they're highly efficient.\nHowever, commands that manipulate elements within a list are usually O(n).\nExamples of these include [`LINDEX`](https://redis.io/docs/latest/commands/lindex), [`LINSERT`](https://redis.io/docs/latest/commands/linsert), and [`LSET`](https://redis.io/docs/latest/commands/lset).\nExercise caution when running these commands, mainly when operating on large lists."
    },
    {
      "id": "alternatives",
      "title": "Alternatives",
      "role": "content",
      "text": "Consider [Redis streams](https://redis.io/docs/latest/develop/data-types/streams) as an alternative to lists when you need to store and process an indeterminate series of events."
    },
    {
      "id": "learn-more",
      "title": "Learn more",
      "role": "related",
      "text": "* [Redis Lists Explained](https://www.youtube.com/watch?v=PB5SeOkkxQc) is a short, comprehensive video explainer on Redis lists.\n* [Redis University's RU101](https://university.redis.com/courses/ru101/) covers Redis lists in detail."
    }
  ],
  "examples": [
    {
      "id": "examples-ex0",
      "language": "plaintext",
      "code": "> LPUSH bikes:repairs bike:1\n(integer) 1\n> LPUSH bikes:repairs bike:2\n(integer) 2\n> RPOP bikes:repairs\n\"bike:1\"\n> RPOP bikes:repairs\n\"bike:2\"",
      "section_id": "examples"
    },
    {
      "id": "examples-ex1",
      "language": "csharp",
      "code": "long res1 = db.ListLeftPush(\"bikes:repairs\", \"bike:1\");\n        Console.WriteLine(res1);    // >>> 1\n\n        long res2 = db.ListLeftPush(\"bikes:repairs\", \"bike:2\");\n        Console.WriteLine(res2);    // >>> 2\n\n        RedisValue res3 = db.ListRightPop(\"bikes:repairs\");\n        Console.WriteLine(res3);    // >>> \"bike:1\"\n\n        RedisValue res4 = db.ListRightPop(\"bikes:repairs\");\n        Console.WriteLine(res4); // >>> \"bike:2\"",
      "section_id": "examples"
    },
    {
      "id": "examples-ex2",
      "language": "csharp",
      "code": "long res1 = db.ListLeftPush(\"bikes:repairs\", \"bike:1\");\n        Console.WriteLine(res1);    // >>> 1\n\n        long res2 = db.ListLeftPush(\"bikes:repairs\", \"bike:2\");\n        Console.WriteLine(res2);    // >>> 2\n\n        RedisValue res3 = db.ListRightPop(\"bikes:repairs\");\n        Console.WriteLine(res3);    // >>> \"bike:1\"\n\n        RedisValue res4 = db.ListRightPop(\"bikes:repairs\");\n        Console.WriteLine(res4); // >>> \"bike:2\"",
      "section_id": "examples"
    },
    {
      "id": "examples-ex3",
      "language": "csharp",
      "code": "long res1 = db.ListLeftPush(\"bikes:repairs\", \"bike:1\");\n        Console.WriteLine(res1);    // >>> 1\n\n        long res2 = db.ListLeftPush(\"bikes:repairs\", \"bike:2\");\n        Console.WriteLine(res2);    // >>> 2\n\n        RedisValue res3 = db.ListRightPop(\"bikes:repairs\");\n        Console.WriteLine(res3);    // >>> \"bike:1\"\n\n        RedisValue res4 = db.ListRightPop(\"bikes:repairs\");\n        Console.WriteLine(res4); // >>> \"bike:2\"",
      "section_id": "examples"
    },
    {
      "id": "examples-ex4",
      "language": "csharp",
      "code": "long res1 = db.ListLeftPush(\"bikes:repairs\", \"bike:1\");\n        Console.WriteLine(res1);    // >>> 1\n\n        long res2 = db.ListLeftPush(\"bikes:repairs\", \"bike:2\");\n        Console.WriteLine(res2);    // >>> 2\n\n        RedisValue res3 = db.ListRightPop(\"bikes:repairs\");\n        Console.WriteLine(res3);    // >>> \"bike:1\"\n\n        RedisValue res4 = db.ListRightPop(\"bikes:repairs\");\n        Console.WriteLine(res4); // >>> \"bike:2\"",
      "section_id": "examples"
    },
    {
      "id": "examples-ex5",
      "language": "go",
      "code": "res1, err := rdb.LPush(ctx, \"bikes:repairs\", \"bike:1\").Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(res1) // >>> 1\n\n\tres2, err := rdb.LPush(ctx, \"bikes:repairs\", \"bike:2\").Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(res2) // >>> 2\n\n\tres3, err := rdb.RPop(ctx, \"bikes:repairs\").Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(res3) // >>> bike:1\n\n\tres4, err := rdb.RPop(ctx, \"bikes:repairs\").Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(res4) // >>> bike:2",
      "section_id": "examples"
    },
    {
      "id": "examples-ex6",
      "language": "java",
      "code": "CompletableFuture<Void> queue = asyncCommands.lpush(\"bikes:repairs\", \"bike:1\").thenCompose(res1 -> {\n                System.out.println(res1); // >>> 1\n\n                return asyncCommands.lpush(\"bikes:repairs\", \"bike:2\");\n            }).thenCompose(res2 -> {\n                System.out.println(res2); // >>> 2\n\n                return asyncCommands.rpop(\"bikes:repairs\");\n            }).thenCompose(res3 -> {\n                System.out.println(res3); // >>> bike:1\n\n                return asyncCommands.rpop(\"bikes:repairs\");\n            })\n                    .thenAccept(System.out::println) // >>> bike:2\n                    .toCompletableFuture();",
      "section_id": "examples"
    },
    {
      "id": "examples-ex7",
      "language": "java",
      "code": "long res1 = jedis.lpush(\"bikes:repairs\", \"bike:1\");\n        System.out.println(res1);  // >>> 1\n\n        long res2 = jedis.lpush(\"bikes:repairs\", \"bike:2\");\n        System.out.println(res2);  // >>> 2\n\n        String res3 = jedis.rpop(\"bikes:repairs\");\n        System.out.println(res3);  // >>> bike:1\n\n        String res4 = jedis.rpop(\"bikes:repairs\");\n        System.out.println(res4); // >>> bike:2",
      "section_id": "examples"
    },
    {
      "id": "examples-ex8",
      "language": "javascript",
      "code": "const res1 = await client.lPush('bikes:repairs', 'bike:1');\nconsole.log(res1);  // 1\n\nconst res2 = await client.lPush('bikes:repairs', 'bike:2');\nconsole.log(res2);  // 2\n\nconst res3 = await client.rPop('bikes:repairs');\nconsole.log(res3);  // bike:1\n\nconst res4 = await client.rPop('bikes:repairs');\nconsole.log(res4);  // bike:2",
      "section_id": "examples"
    },
    {
      "id": "examples-ex9",
      "language": "php",
      "code": "$res1 = $r->lpush('bikes:repairs', 'bike:1');\n        echo $res1 . PHP_EOL;\n        // >>> 1\n\n        $res2 = $r->lpush('bikes:repairs', 'bike:2');\n        echo $res2 . PHP_EOL;\n        // >>> 2\n\n        $res3 = $r->rpop('bikes:repairs');\n        echo $res3 . PHP_EOL;\n        // >>> bike:1\n\n        $res4 = $r->rpop('bikes:repairs');\n        echo $res4 . PHP_EOL;\n        // >>> bike:2",
      "section_id": "examples"
    },
    {
      "id": "examples-ex10",
      "language": "python",
      "code": "res1 = r.lpush(\"bikes:repairs\", \"bike:1\")\nprint(res1)  # >>> 1\n\nres2 = r.lpush(\"bikes:repairs\", \"bike:2\")\nprint(res2)  # >>> 2\n\nres3 = r.rpop(\"bikes:repairs\")\nprint(res3)  # >>> bike:1\n\nres4 = r.rpop(\"bikes:repairs\")\nprint(res4)  # >>> bike:2",
      "section_id": "examples"
    },
    {
      "id": "examples-ex11",
      "language": "ruby",
      "code": "res1 = r.lpush('bikes:repairs', 'bike:1')\nputs res1 # >>> 1\n\nres2 = r.lpush('bikes:repairs', 'bike:2')\nputs res2 # >>> 2\n\nres3 = r.rpop('bikes:repairs')\nputs res3 # >>> bike:1\n\nres4 = r.rpop('bikes:repairs')\nputs res4 # >>> bike:2",
      "section_id": "examples"
    },
    {
      "id": "examples-ex12",
      "language": "rust",
      "code": "if let Ok(res) = r.lpush(\"bikes:repairs\", \"bike:1\").await {\n            let res: usize = res;\n            println!(\"{res}\"); // >>> 1\n        }\n\n        if let Ok(res) = r.lpush(\"bikes:repairs\", \"bike:2\").await {\n            let res: usize = res;\n            println!(\"{res}\"); // >>> 2\n        }\n\n        if let Ok(res) = r.rpop(\"bikes:repairs\", None).await {\n            let res: Option<String> = res;\n            print_optional_string(res.clone()); // >>> bike:1\n        }\n\n        if let Ok(res) = r.rpop(\"bikes:repairs\", None).await {\n            let res: Option<String> = res;\n            print_optional_string(res.clone()); // >>> bike:2\n        }",
      "section_id": "examples"
    },
    {
      "id": "examples-ex13",
      "language": "rust",
      "code": "if let Ok(res) = r.lpush(\"bikes:repairs\", \"bike:1\") {\n            let res: usize = res;\n            println!(\"{res}\"); // >>> 1\n        }\n\n        if let Ok(res) = r.lpush(\"bikes:repairs\", \"bike:2\") {\n            let res: usize = res;\n            println!(\"{res}\"); // >>> 2\n        }\n\n        if let Ok(res) = r.rpop(\"bikes:repairs\", None) {\n            let res: Option<String> = res;\n            print_optional_string(res.clone()); // >>> bike:1\n        }\n\n        if let Ok(res) = r.rpop(\"bikes:repairs\", None) {\n            let res: Option<String> = res;\n            print_optional_string(res.clone()); // >>> bike:2\n        }",
      "section_id": "examples"
    },
    {
      "id": "examples-ex14",
      "language": "plaintext",
      "code": "> LPUSH bikes:repairs bike:1\n(integer) 1\n> LPUSH bikes:repairs bike:2\n(integer) 2\n> LPOP bikes:repairs\n\"bike:2\"\n> LPOP bikes:repairs\n\"bike:1\"",
      "section_id": "examples"
    },
    {
      "id": "examples-ex15",
      "language": "csharp",
      "code": "long res5 = db.ListLeftPush(\"bikes:repairs\", \"bike:1\");\n        Console.WriteLine(res5);    // >>> 1\n\n        long res6 = db.ListLeftPush(\"bikes:repairs\", \"bike:2\");\n        Console.WriteLine(res6);    // >>> 2\n\n        RedisValue res7 = db.ListLeftPop(\"bikes:repairs\");\n        Console.WriteLine(res7);    // >>> \"bike:2\"\n\n        RedisValue res8 = db.ListLeftPop(\"bikes:repairs\");\n        Console.WriteLine(res8);    // >>> \"bike:1\"",
      "section_id": "examples"
    },
    {
      "id": "examples-ex16",
      "language": "csharp",
      "code": "long res5 = db.ListLeftPush(\"bikes:repairs\", \"bike:1\");\n        Console.WriteLine(res5);    // >>> 1\n\n        long res6 = db.ListLeftPush(\"bikes:repairs\", \"bike:2\");\n        Console.WriteLine(res6);    // >>> 2\n\n        RedisValue res7 = db.ListLeftPop(\"bikes:repairs\");\n        Console.WriteLine(res7);    // >>> \"bike:2\"\n\n        RedisValue res8 = db.ListLeftPop(\"bikes:repairs\");\n        Console.WriteLine(res8);    // >>> \"bike:1\"",
      "section_id": "examples"
    },
    {
      "id": "examples-ex17",
      "language": "csharp",
      "code": "long res5 = db.ListLeftPush(\"bikes:repairs\", \"bike:1\");\n        Console.WriteLine(res5);    // >>> 1\n\n        long res6 = db.ListLeftPush(\"bikes:repairs\", \"bike:2\");\n        Console.WriteLine(res6);    // >>> 2\n\n        RedisValue res7 = db.ListLeftPop(\"bikes:repairs\");\n        Console.WriteLine(res7);    // >>> \"bike:2\"\n\n        RedisValue res8 = db.ListLeftPop(\"bikes:repairs\");\n        Console.WriteLine(res8);    // >>> \"bike:1\"",
      "section_id": "examples"
    },
    {
      "id": "examples-ex18",
      "language": "csharp",
      "code": "long res5 = db.ListLeftPush(\"bikes:repairs\", \"bike:1\");\n        Console.WriteLine(res5);    // >>> 1\n\n        long res6 = db.ListLeftPush(\"bikes:repairs\", \"bike:2\");\n        Console.WriteLine(res6);    // >>> 2\n\n        RedisValue res7 = db.ListLeftPop(\"bikes:repairs\");\n        Console.WriteLine(res7);    // >>> \"bike:2\"\n\n        RedisValue res8 = db.ListLeftPop(\"bikes:repairs\");\n        Console.WriteLine(res8);    // >>> \"bike:1\"",
      "section_id": "examples"
    },
    {
      "id": "examples-ex19",
      "language": "go",
      "code": "res5, err := rdb.LPush(ctx, \"bikes:repairs\", \"bike:1\").Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(res5) // >>> 1\n\n\tres6, err := rdb.LPush(ctx, \"bikes:repairs\", \"bike:2\").Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(res6) // >>> 2\n\n\tres7, err := rdb.LPop(ctx, \"bikes:repairs\").Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(res7) // >>> bike:2\n\n\tres8, err := rdb.LPop(ctx, \"bikes:repairs\").Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(res8) // >>> bike:1",
      "section_id": "examples"
    },
    {
      "id": "examples-ex20",
      "language": "java",
      "code": "CompletableFuture<Void> stack = asyncCommands.lpush(\"bikes:repairs\", \"bike:1\").thenCompose(res4 -> {\n                System.out.println(res4); // >>> 1\n\n                return asyncCommands.lpush(\"bikes:repairs\", \"bike:2\");\n            }).thenCompose(res5 -> {\n                System.out.println(res5); // >>> 2\n\n                return asyncCommands.lpop(\"bikes:repairs\");\n            }).thenCompose(res6 -> {\n                System.out.println(res6); // >>> bike:2\n\n                return asyncCommands.lpop(\"bikes:repairs\");\n            })\n                    .thenAccept(System.out::println) // >>> bike:1\n                    .toCompletableFuture();",
      "section_id": "examples"
    },
    {
      "id": "examples-ex21",
      "language": "java",
      "code": "long res5 = jedis.lpush(\"bikes:repairs\", \"bike:1\");\n        System.out.println(res5);  // >>> 1\n\n        long res6 = jedis.lpush(\"bikes:repairs\", \"bike:2\");\n        System.out.println(res6);  // >>> 2\n\n        String res7 = jedis.lpop(\"bikes:repairs\");\n        System.out.println(res7);  // >>> bike:2\n\n        String res8 = jedis.lpop(\"bikes:repairs\");\n        System.out.println(res8);  // >>> bike:1",
      "section_id": "examples"
    },
    {
      "id": "examples-ex22",
      "language": "javascript",
      "code": "const res5 = await client.lPush('bikes:repairs', 'bike:1');\nconsole.log(res5);  // 1\n\nconst res6 = await client.lPush('bikes:repairs', 'bike:2');\nconsole.log(res6); // 2\n\nconst res7 = await client.lPop('bikes:repairs');\nconsole.log(res7);  // bike:2\n\nconst res8 = await client.lPop('bikes:repairs');\nconsole.log(res8);  // bike:1",
      "section_id": "examples"
    },
    {
      "id": "examples-ex23",
      "language": "php",
      "code": "$res5 = $r->lpush('bikes:repairs', 'bike:1');\n        echo $res5 . PHP_EOL;\n        // >>> 1\n\n        $res6 = $r->lpush('bikes:repairs', 'bike:2');\n        echo $res6 . PHP_EOL;\n        // >>> 2\n\n        $res7 = $r->lpop('bikes:repairs');\n        echo $res7 . PHP_EOL;\n        // >>> bike:2\n\n        $res8 = $r->lpop('bikes:repairs');\n        echo $res8 . PHP_EOL;\n        // >>> bike:1",
      "section_id": "examples"
    },
    {
      "id": "examples-ex24",
      "language": "python",
      "code": "res5 = r.lpush(\"bikes:repairs\", \"bike:1\")\nprint(res5)  # >>> 1\n\nres6 = r.lpush(\"bikes:repairs\", \"bike:2\")\nprint(res6)  # >>> 2\n\nres7 = r.lpop(\"bikes:repairs\")\nprint(res7)  # >>> bike:2\n\nres8 = r.lpop(\"bikes:repairs\")\nprint(res8)  # >>> bike:1",
      "section_id": "examples"
    },
    {
      "id": "examples-ex25",
      "language": "ruby",
      "code": "res5 = r.lpush('bikes:repairs', 'bike:1')\nputs res5 # >>> 1\n\nres6 = r.lpush('bikes:repairs', 'bike:2')\nputs res6 # >>> 2\n\nres7 = r.lpop('bikes:repairs')\nputs res7 # >>> bike:2\n\nres8 = r.lpop('bikes:repairs')\nputs res8 # >>> bike:1",
      "section_id": "examples"
    },
    {
      "id": "examples-ex26",
      "language": "rust",
      "code": "if let Ok(res) = r.lpush(\"bikes:repairs\", \"bike:1\").await {\n            let res: usize = res;\n            println!(\"{res}\"); // >>> 1\n        }\n\n        if let Ok(res) = r.lpush(\"bikes:repairs\", \"bike:2\").await {\n            let res: usize = res;\n            println!(\"{res}\"); // >>> 2\n        }\n\n        if let Ok(res) = r.lpop(\"bikes:repairs\", None).await {\n            let res: Option<String> = res;\n            print_optional_string(res.clone()); // >>> bike:2\n        }\n\n        if let Ok(res) = r.lpop(\"bikes:repairs\", None).await {\n            let res: Option<String> = res;\n            print_optional_string(res.clone()); // >>> bike:1\n        }",
      "section_id": "examples"
    },
    {
      "id": "examples-ex27",
      "language": "rust",
      "code": "if let Ok(res) = r.lpush(\"bikes:repairs\", \"bike:1\") {\n            let res: usize = res;\n            println!(\"{res}\"); // >>> 1\n        }\n\n        if let Ok(res) = r.lpush(\"bikes:repairs\", \"bike:2\") {\n            let res: usize = res;\n            println!(\"{res}\"); // >>> 2\n        }\n\n        if let Ok(res) = r.lpop(\"bikes:repairs\", None) {\n            let res: Option<String> = res;\n            print_optional_string(res.clone()); // >>> bike:2\n        }\n\n        if let Ok(res) = r.lpop(\"bikes:repairs\", None) {\n            let res: Option<String> = res;\n            print_optional_string(res.clone()); // >>> bike:1\n        }",
      "section_id": "examples"
    },
    {
      "id": "examples-ex28",
      "language": "plaintext",
      "code": "> LLEN bikes:repairs\n(integer) 0",
      "section_id": "examples"
    },
    {
      "id": "examples-ex29",
      "language": "csharp",
      "code": "long res9 = db.ListLength(\"bikes:repairs\");\n        Console.WriteLine(res9);    // >>> 0",
      "section_id": "examples"
    },
    {
      "id": "examples-ex30",
      "language": "csharp",
      "code": "long res9 = db.ListLength(\"bikes:repairs\");\n        Console.WriteLine(res9);    // >>> 0",
      "section_id": "examples"
    },
    {
      "id": "examples-ex31",
      "language": "csharp",
      "code": "long res9 = db.ListLength(\"bikes:repairs\");\n        Console.WriteLine(res9);    // >>> 0",
      "section_id": "examples"
    },
    {
      "id": "examples-ex32",
      "language": "csharp",
      "code": "long res9 = db.ListLength(\"bikes:repairs\");\n        Console.WriteLine(res9);    // >>> 0",
      "section_id": "examples"
    },
    {
      "id": "examples-ex33",
      "language": "go",
      "code": "res9, err := rdb.LLen(ctx, \"bikes:repairs\").Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(res9) // >>> 0",
      "section_id": "examples"
    },
    {
      "id": "examples-ex34",
      "language": "java",
      "code": "CompletableFuture<Void> llen = asyncCommands.llen(\"bikes:repairs\")\n                    .thenAccept(System.out::println) // >>> 0\n                    .toCompletableFuture();",
      "section_id": "examples"
    },
    {
      "id": "examples-ex35",
      "language": "java",
      "code": "long res9 = jedis.llen(\"bikes:repairs\");\n        System.out.println(res9);  // >>> 0",
      "section_id": "examples"
    },
    {
      "id": "examples-ex36",
      "language": "javascript",
      "code": "const res9 = await client.lLen('bikes:repairs');\nconsole.log(res9); // 0",
      "section_id": "examples"
    },
    {
      "id": "examples-ex37",
      "language": "php",
      "code": "$res9 = $r->llen('bikes:repairs');\n        echo $res9 . PHP_EOL;\n        // >>> 0",
      "section_id": "examples"
    },
    {
      "id": "examples-ex38",
      "language": "python",
      "code": "res9 = r.llen(\"bikes:repairs\")\nprint(res9)  # >>> 0",
      "section_id": "examples"
    },
    {
      "id": "examples-ex39",
      "language": "ruby",
      "code": "res9 = r.llen('bikes:repairs')\nputs res9 # >>> 0",
      "section_id": "examples"
    },
    {
      "id": "examples-ex40",
      "language": "rust",
      "code": "if let Ok(res) = r.llen(\"bikes:repairs\").await {\n            let res: usize = res;\n            println!(\"{res}\"); // >>> 0\n        }",
      "section_id": "examples"
    },
    {
      "id": "examples-ex41",
      "language": "rust",
      "code": "if let Ok(res) = r.llen(\"bikes:repairs\") {\n            let res: usize = res;\n            println!(\"{res}\"); // >>> 0\n        }",
      "section_id": "examples"
    },
    {
      "id": "examples-ex42",
      "language": "plaintext",
      "code": "> LPUSH bikes:repairs bike:1\n(integer) 1\n> LPUSH bikes:repairs bike:2\n(integer) 2\n> LMOVE bikes:repairs bikes:finished LEFT LEFT\n\"bike:2\"\n> LRANGE bikes:repairs 0 -1\n1) \"bike:1\"\n> LRANGE bikes:finished 0 -1\n1) \"bike:2\"",
      "section_id": "examples"
    },
    {
      "id": "examples-ex43",
      "language": "csharp",
      "code": "long res10 = db.ListLeftPush(\"{bikes}:repairs\", \"bike:1\");\n        Console.WriteLine(res10);   // >>> 1\n\n        long res11 = db.ListLeftPush(\"{bikes}:repairs\", \"bike:2\");\n        Console.WriteLine(res11);   // >>> 2\n\n        RedisValue res12 = db.ListMove(\"{bikes}:repairs\", \"{bikes}:finished\", ListSide.Left, ListSide.Left);\n        Console.Write(res12);   // >>> \"bike:2\"\n\n        RedisValue[] res13 = db.ListRange(\"{bikes}:repairs\", 0, -1);\n        Console.WriteLine(string.Join(\", \", res13));    // >>> \"bike:1\"\n\n        RedisValue[] res14 = db.ListRange(\"{bikes}:finished\", 0, -1);\n        Console.WriteLine(string.Join(\", \", res14));    // >>> \"bike:2\"",
      "section_id": "examples"
    },
    {
      "id": "examples-ex44",
      "language": "csharp",
      "code": "long res10 = db.ListLeftPush(\"{bikes}:repairs\", \"bike:1\");\n        Console.WriteLine(res10);   // >>> 1\n\n        long res11 = db.ListLeftPush(\"{bikes}:repairs\", \"bike:2\");\n        Console.WriteLine(res11);   // >>> 2\n\n        RedisValue res12 = db.ListMove(\"{bikes}:repairs\", \"{bikes}:finished\", ListSide.Left, ListSide.Left);\n        Console.Write(res12);   // >>> \"bike:2\"\n\n        RedisValue[] res13 = db.ListRange(\"{bikes}:repairs\", 0, -1);\n        Console.WriteLine(string.Join(\", \", res13));    // >>> \"bike:1\"\n\n        RedisValue[] res14 = db.ListRange(\"{bikes}:finished\", 0, -1);\n        Console.WriteLine(string.Join(\", \", res14));    // >>> \"bike:2\"",
      "section_id": "examples"
    },
    {
      "id": "examples-ex45",
      "language": "csharp",
      "code": "long res10 = db.ListLeftPush(\"{bikes}:repairs\", \"bike:1\");\n        Console.WriteLine(res10);   // >>> 1\n\n        long res11 = db.ListLeftPush(\"{bikes}:repairs\", \"bike:2\");\n        Console.WriteLine(res11);   // >>> 2\n\n        RedisValue res12 = db.ListMove(\"{bikes}:repairs\", \"{bikes}:finished\", ListSide.Left, ListSide.Left);\n        Console.Write(res12);   // >>> \"bike:2\"\n\n        RedisValue[] res13 = db.ListRange(\"{bikes}:repairs\", 0, -1);\n        Console.WriteLine(string.Join(\", \", res13));    // >>> \"bike:1\"\n\n        RedisValue[] res14 = db.ListRange(\"{bikes}:finished\", 0, -1);\n        Console.WriteLine(string.Join(\", \", res14));    // >>> \"bike:2\"",
      "section_id": "examples"
    },
    {
      "id": "examples-ex46",
      "language": "csharp",
      "code": "long res10 = db.ListLeftPush(\"{bikes}:repairs\", \"bike:1\");\n        Console.WriteLine(res10);   // >>> 1\n\n        long res11 = db.ListLeftPush(\"{bikes}:repairs\", \"bike:2\");\n        Console.WriteLine(res11);   // >>> 2\n\n        RedisValue res12 = db.ListMove(\"{bikes}:repairs\", \"{bikes}:finished\", ListSide.Left, ListSide.Left);\n        Console.Write(res12);   // >>> \"bike:2\"\n\n        RedisValue[] res13 = db.ListRange(\"{bikes}:repairs\", 0, -1);\n        Console.WriteLine(string.Join(\", \", res13));    // >>> \"bike:1\"\n\n        RedisValue[] res14 = db.ListRange(\"{bikes}:finished\", 0, -1);\n        Console.WriteLine(string.Join(\", \", res14));    // >>> \"bike:2\"",
      "section_id": "examples"
    },
    {
      "id": "examples-ex47",
      "language": "go",
      "code": "res10, err := rdb.LPush(ctx, \"bikes:repairs\", \"bike:1\").Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(res10) // >>> 1\n\n\tres11, err := rdb.LPush(ctx, \"bikes:repairs\", \"bike:2\").Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(res11) // >>> 2\n\n\tres12, err := rdb.LMove(ctx, \"bikes:repairs\", \"bikes:finished\", \"LEFT\", \"LEFT\").Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(res12) // >>> bike:2\n\n\tres13, err := rdb.LRange(ctx, \"bikes:repairs\", 0, -1).Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(res13) // >>> [bike:1]\n\n\tres14, err := rdb.LRange(ctx, \"bikes:finished\", 0, -1).Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(res14) // >>> [bike:2]",
      "section_id": "examples"
    },
    {
      "id": "examples-ex48",
      "language": "java",
      "code": "CompletableFuture<Void> lmovelrange = asyncCommands.lpush(\"bikes:repairs\", \"bike:1\").thenCompose(res7 -> {\n                System.out.println(res7); // >>> 1\n\n                return asyncCommands.lpush(\"bikes:repairs\", \"bike:2\");\n            }).thenCompose(res8 -> {\n                System.out.println(res8); // >>> 2\n\n                return asyncCommands.lmove(\"bikes:repairs\", \"bikes:finished\", LMoveArgs.Builder.leftLeft());\n            }).thenCompose(res9 -> {\n                System.out.println(res9); // >>> bike:2\n\n                return asyncCommands.lrange(\"bikes:repairs\", 0, -1);\n            }).thenCompose(res10 -> {\n                System.out.println(res10); // >>> [bike:1]\n\n                return asyncCommands.lrange(\"bikes:finished\", 0, -1);\n            })\n                    .thenAccept(System.out::println) // >>> [bike:2]\n                    .toCompletableFuture();",
      "section_id": "examples"
    },
    {
      "id": "examples-ex49",
      "language": "java",
      "code": "long res10 = jedis.lpush(\"bikes:repairs\", \"bike:1\");\n        System.out.println(res10);  // >>> 1\n\n        long res11 = jedis.lpush(\"bikes:repairs\", \"bike:2\");\n        System.out.println(res11);  // >>> 2\n\n        String res12 = jedis.lmove(\"bikes:repairs\", \"bikes:finished\", ListDirection.LEFT, ListDirection.LEFT);\n        System.out.println(res12);  // >>> bike:2\n\n        List<String> res13 = jedis.lrange(\"bikes:repairs\", 0, -1);\n        System.out.println(res13);  // >>> [bike:1]\n\n        List<String> res14 = jedis.lrange(\"bikes:finished\", 0, -1);\n        System.out.println(res14);  // >>> [bike:2]",
      "section_id": "examples"
    },
    {
      "id": "examples-ex50",
      "language": "javascript",
      "code": "const res10 = await client.lPush('bikes:repairs', 'bike:1');\nconsole.log(res10);  // 1\n\nconst res11 = await client.lPush('bikes:repairs', 'bike:2');\nconsole.log(res11);  // 2\n\nconst res12 = await client.lMove('bikes:repairs', 'bikes:finished', 'LEFT', 'LEFT');\nconsole.log(res12);  // 'bike:2'\n\nconst res13 = await client.lRange('bikes:repairs', 0, -1);\nconsole.log(res13);  // ['bike:1']\n\nconst res14 = await client.lRange('bikes:finished', 0, -1);\nconsole.log(res14);  // ['bike:2']",
      "section_id": "examples"
    },
    {
      "id": "examples-ex51",
      "language": "php",
      "code": "$res10 = $r->lpush('bikes:repairs', 'bike:1');\n        echo $res10 . PHP_EOL;\n        // >>> 1\n\n        $res11 = $r->lpush('bikes:repairs', 'bike:2');\n        echo $res11 . PHP_EOL;\n        // >>> 2\n\n        $res12 = $r->lmove('bikes:repairs', 'bikes:finished', 'LEFT', 'LEFT');\n        echo $res12 . PHP_EOL;\n        // >>> 'bike:2'\n\n        $res13 = $r->lrange('bikes:repairs', 0, -1);\n        echo json_encode($res13) . PHP_EOL;\n        // >>> ['bike:1']\n\n        $res14 = $r->lrange('bikes:finished', 0, -1);\n        echo json_encode($res14) . PHP_EOL;\n        // >>> ['bike:2']",
      "section_id": "examples"
    },
    {
      "id": "examples-ex52",
      "language": "python",
      "code": "res10 = r.lpush(\"bikes:repairs\", \"bike:1\")\nprint(res10)  # >>> 1\n\nres11 = r.lpush(\"bikes:repairs\", \"bike:2\")\nprint(res11)  # >>> 2\n\nres12 = r.lmove(\"bikes:repairs\", \"bikes:finished\", \"LEFT\", \"LEFT\")\nprint(res12)  # >>> 'bike:2'\n\nres13 = r.lrange(\"bikes:repairs\", 0, -1)\nprint(res13)  # >>> ['bike:1']\n\nres14 = r.lrange(\"bikes:finished\", 0, -1)\nprint(res14)  # >>> ['bike:2']",
      "section_id": "examples"
    },
    {
      "id": "examples-ex53",
      "language": "ruby",
      "code": "res10 = r.lpush('bikes:repairs', 'bike:1')\nputs res10 # >>> 1\n\nres11 = r.lpush('bikes:repairs', 'bike:2')\nputs res11 # >>> 2\n\nres12 = r.lmove('bikes:repairs', 'bikes:finished', 'LEFT', 'LEFT')\nputs res12 # >>> bike:2\n\nres13 = r.lrange('bikes:repairs', 0, -1)\nputs res13.inspect # >>> [\"bike:1\"]\n\nres14 = r.lrange('bikes:finished', 0, -1)\nputs res14.inspect # >>> [\"bike:2\"]",
      "section_id": "examples"
    },
    {
      "id": "examples-ex54",
      "language": "rust",
      "code": "if let Ok(res) = r.lpush(\"bikes:repairs\", \"bike:1\").await {\n            let res: usize = res;\n            println!(\"{res}\"); // >>> 1\n        }\n\n        if let Ok(res) = r.lpush(\"bikes:repairs\", \"bike:2\").await {\n            let res: usize = res;\n            println!(\"{res}\"); // >>> 2\n        }\n\n        if let Ok(res) = r\n            .lmove(\n                \"bikes:repairs\",\n                \"bikes:finished\",\n                Direction::Left,\n                Direction::Left,\n            )\n            .await\n        {\n            let res: String = res;\n            println!(\"{res}\"); // >>> bike:2\n        }\n\n        if let Ok(res) = r.lrange(\"bikes:repairs\", 0, -1).await {\n            let res: Vec<String> = res;\n            println!(\"{res:?}\"); // >>> [\"bike:1\"]\n        }\n\n        if let Ok(res) = r.lrange(\"bikes:finished\", 0, -1).await {\n            let res: Vec<String> = res;\n            println!(\"{res:?}\"); // >>> [\"bike:2\"]\n        }",
      "section_id": "examples"
    },
    {
      "id": "examples-ex55",
      "language": "rust",
      "code": "if let Ok(res) = r.lpush(\"bikes:repairs\", \"bike:1\") {\n            let res: usize = res;\n            println!(\"{res}\"); // >>> 1\n        }\n\n        if let Ok(res) = r.lpush(\"bikes:repairs\", \"bike:2\") {\n            let res: usize = res;\n            println!(\"{res}\"); // >>> 2\n        }\n\n        if let Ok(res) = r.lmove(\n            \"bikes:repairs\",\n            \"bikes:finished\",\n            Direction::Left,\n            Direction::Left,\n        ) {\n            let res: String = res;\n            println!(\"{res}\"); // >>> bike:2\n        }\n\n        if let Ok(res) = r.lrange(\"bikes:repairs\", 0, -1) {\n            let res: Vec<String> = res;\n            println!(\"{res:?}\"); // >>> [\"bike:1\"]\n        }\n\n        if let Ok(res) = r.lrange(\"bikes:finished\", 0, -1) {\n            let res: Vec<String> = res;\n            println!(\"{res:?}\"); // >>> [\"bike:2\"]\n        }",
      "section_id": "examples"
    },
    {
      "id": "examples-ex56",
      "language": "plaintext",
      "code": "> DEL bikes:repairs\n(integer) 1\n> RPUSH bikes:repairs bike:1 bike:2 bike:3 bike:4 bike:5\n(integer) 5\n> LTRIM bikes:repairs 0 2\nOK\n> LRANGE bikes:repairs 0 -1\n1) \"bike:1\"\n2) \"bike:2\"\n3) \"bike:3\"",
      "section_id": "examples"
    },
    {
      "id": "examples-ex57",
      "language": "csharp",
      "code": "long res49 = db.ListLeftPush(\"bikes:repairs\", [\"bike:1\", \"bike:2\", \"bike:3\", \"bike:4\", \"bike:5\"]);\n        Console.WriteLine(res49);   // >>> 5\n\n        db.ListTrim(\"bikes:repairs\", 0, 2);\n        RedisValue[] res50 = db.ListRange(\"bikes:repairs\", 0, -1);\n        Console.WriteLine(string.Join(\", \", res50));    // >>> \"bike:5, bike:4, bike:3\"",
      "section_id": "examples"
    },
    {
      "id": "examples-ex58",
      "language": "csharp",
      "code": "db.KeyDelete(\"bikes:repairs\");\n\n        long res49 = db.ListLeftPush(\"bikes:repairs\", [\"bike:1\", \"bike:2\", \"bike:3\", \"bike:4\", \"bike:5\"]);\n        Console.WriteLine(res49);   // >>> 5\n\n        db.ListTrim(\"bikes:repairs\", 0, 2);\n        RedisValue[] res50 = db.ListRange(\"bikes:repairs\", 0, -1);\n        Console.WriteLine(string.Join(\", \", res50));    // >>> \"bike:5, bike:4, bike:3\"",
      "section_id": "examples"
    },
    {
      "id": "examples-ex59",
      "language": "csharp",
      "code": "long res49 = db.ListLeftPush(\"bikes:repairs\", [\"bike:1\", \"bike:2\", \"bike:3\", \"bike:4\", \"bike:5\"]);\n        Console.WriteLine(res49);   // >>> 5\n\n        db.ListTrim(\"bikes:repairs\", 0, 2);\n        RedisValue[] res50 = db.ListRange(\"bikes:repairs\", 0, -1);\n        Console.WriteLine(string.Join(\", \", res50));    // >>> \"bike:5, bike:4, bike:3\"",
      "section_id": "examples"
    },
    {
      "id": "examples-ex60",
      "language": "csharp",
      "code": "db.KeyDelete(\"bikes:repairs\");\n\n        long res49 = db.ListLeftPush(\"bikes:repairs\", [\"bike:1\", \"bike:2\", \"bike:3\", \"bike:4\", \"bike:5\"]);\n        Console.WriteLine(res49);   // >>> 5\n\n        db.ListTrim(\"bikes:repairs\", 0, 2);\n        RedisValue[] res50 = db.ListRange(\"bikes:repairs\", 0, -1);\n        Console.WriteLine(string.Join(\", \", res50));    // >>> \"bike:5, bike:4, bike:3\"",
      "section_id": "examples"
    },
    {
      "id": "examples-ex61",
      "language": "go",
      "code": "rdb.Del(ctx, \"bikes:repairs\")\n\n\tres51, err := rdb.LPush(ctx, \"bikes:repairs\", \"bike:1\", \"bike:2\", \"bike:3\", \"bike:4\", \"bike:5\").Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(res51) // >>> 5\n\n\tres52, err := rdb.LTrim(ctx, \"bikes:repairs\", 0, 2).Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(res52) // >>> OK\n\n\tres53, err := rdb.LRange(ctx, \"bikes:repairs\", 0, -1).Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(res53) // >>> [bike:5 bike:4 bike:3]",
      "section_id": "examples"
    },
    {
      "id": "examples-ex62",
      "language": "java",
      "code": "CompletableFuture<Void> ltrim1 = asyncCommands\n                    .lpush(\"bikes:repairs\", \"bike:1\", \"bike:2\", \"bike:3\", \"bike:4\", \"bike:5\").thenCompose(res37 -> {\n                        System.out.println(res37); // >>> 5\n\n                        return asyncCommands.ltrim(\"bikes:repairs\", 0, 2);\n                    }).thenCompose(res38 -> {\n                        System.out.println(res38); // >>> OK\n\n                        return asyncCommands.lrange(\"bikes:repairs\", 0, -1);\n                    })\n                    .thenAccept(System.out::println) // >>> [bike:5, bike:4, bike:3]\n                    .toCompletableFuture();",
      "section_id": "examples"
    },
    {
      "id": "examples-ex63",
      "language": "java",
      "code": "jedis.del(\"bikes:repairs\");\n\n        long res48 = jedis.lpush(\"bikes:repairs\", \"bike:1\", \"bike:2\", \"bike:3\", \"bike:4\", \"bike:5\");\n        System.out.println(res48);  // >>> 5\n\n        String res49 = jedis.ltrim(\"bikes:repairs\", 0, 2);\n        System.out.println(res49);  // >>> OK\n\n        List<String> res50 = jedis.lrange(\"bikes:repairs\", 0, -1);\n        System.out.println(res50);  // >>> [bike:5, bike:4, bike:3]",
      "section_id": "examples"
    },
    {
      "id": "examples-ex64",
      "language": "javascript",
      "code": "await client.del('bikes:repairs');\n\nconst res48 = await client.lPush(\n  'bikes:repairs', ['bike:1', 'bike:2', 'bike:3', 'bike:4', 'bike:5']\n);\nconsole.log(res48);  // 5\n\nconst res49 = await client.lTrim('bikes:repairs', 0, 2);\nconsole.log(res49);  // 'OK'\n\nconst res50 = await client.lRange('bikes:repairs', 0, -1);\nconsole.log(res50);  // ['bike:5', 'bike:4', 'bike:3']",
      "section_id": "examples"
    },
    {
      "id": "examples-ex65",
      "language": "php",
      "code": "$res48 = $r->lpush('bikes:repairs', 'bike:1', 'bike:2', 'bike:3', 'bike:4', 'bike:5');\n        echo $res48 . PHP_EOL;\n        // >>> 5\n\n        $res49 = $r->ltrim('bikes:repairs', 0, 2);\n        echo $res49 . PHP_EOL;\n        // >>> True\n\n        $res50 = $r->lrange('bikes:repairs', 0, -1);\n        echo json_encode($res50) . PHP_EOL;\n        // >>> ['bike:5', 'bike:4', 'bike:3']",
      "section_id": "examples"
    },
    {
      "id": "examples-ex66",
      "language": "python",
      "code": "r.delete(\"bikes:repairs\")\n\nres48 = r.lpush(\"bikes:repairs\", \"bike:1\", \"bike:2\", \"bike:3\", \"bike:4\", \"bike:5\")\nprint(res48)  # >>> 5\n\nres49 = r.ltrim(\"bikes:repairs\", 0, 2)\nprint(res49)  # >>> True\n\nres50 = r.lrange(\"bikes:repairs\", 0, -1)\nprint(res50)  # >>> ['bike:5', 'bike:4', 'bike:3']",
      "section_id": "examples"
    },
    {
      "id": "examples-ex67",
      "language": "ruby",
      "code": "r.del('bikes:repairs')\n\nres15 = r.rpush('bikes:repairs', ['bike:1', 'bike:2', 'bike:3', 'bike:4', 'bike:5'])\nputs res15 # >>> 5\n\nres16 = r.ltrim('bikes:repairs', 0, 2)\nputs res16 # >>> OK\n\nres17 = r.lrange('bikes:repairs', 0, -1)\nputs res17.inspect # >>> [\"bike:1\", \"bike:2\", \"bike:3\"]",
      "section_id": "examples"
    },
    {
      "id": "examples-ex68",
      "language": "rust",
      "code": "if let Ok(res) = r.del(\"bikes:repairs\").await {\n            let res: usize = res;\n            println!(\"{res}\"); // >>> 1\n        }\n\n        if let Ok(res) = r\n            .rpush(\n                \"bikes:repairs\",\n                &[\"bike:1\", \"bike:2\", \"bike:3\", \"bike:4\", \"bike:5\"],\n            )\n            .await\n        {\n            let res: usize = res;\n            println!(\"{res}\"); // >>> 5\n        }\n\n        if let Ok(res) = r.ltrim(\"bikes:repairs\", 0, 2).await {\n            let res: () = res;\n            let _ = res;\n            println!(\"OK\"); // >>> OK\n        }\n\n        if let Ok(res) = r.lrange(\"bikes:repairs\", 0, -1).await {\n            let res: Vec<String> = res;\n            println!(\"{res:?}\"); // >>> [\"bike:1\", \"bike:2\", \"bike:3\"]\n        }",
      "section_id": "examples"
    },
    {
      "id": "examples-ex69",
      "language": "rust",
      "code": "if let Ok(res) = r.del(\"bikes:repairs\") {\n            let res: usize = res;\n            println!(\"{res}\"); // >>> 1\n        }\n\n        if let Ok(res) = r.rpush(\"bikes:repairs\", &[\"bike:1\", \"bike:2\", \"bike:3\", \"bike:4\", \"bike:5\"]) {\n            let res: usize = res;\n            println!(\"{res}\"); // >>> 5\n        }\n\n        if let Ok(res) = r.ltrim(\"bikes:repairs\", 0, 2) {\n            let res: () = res;\n            let _ = res;\n            println!(\"OK\"); // >>> OK\n        }\n\n        if let Ok(res) = r.lrange(\"bikes:repairs\", 0, -1) {\n            let res: Vec<String> = res;\n            println!(\"{res:?}\"); // >>> [\"bike:1\", \"bike:2\", \"bike:3\"]\n        }",
      "section_id": "examples"
    },
    {
      "id": "first-steps-with-redis-lists-ex0",
      "language": "plaintext",
      "code": "> DEL bikes:repairs\n(integer) 1\n> RPUSH bikes:repairs bike:1\n(integer) 1\n> RPUSH bikes:repairs bike:2\n(integer) 2\n> LPUSH bikes:repairs bike:important_bike\n(integer) 3\n> LRANGE bikes:repairs 0 -1\n1) \"bike:important_bike\"\n2) \"bike:1\"\n3) \"bike:2\"",
      "section_id": "first-steps-with-redis-lists"
    },
    {
      "id": "first-steps-with-redis-lists-ex1",
      "language": "csharp",
      "code": "long res15 = db.ListRightPush(\"bikes:repairs\", \"bike:1\");\n        Console.WriteLine(res15);   // >>> 1\n\n        long res16 = db.ListRightPush(\"bikes:repairs\", \"bike:2\");\n        Console.WriteLine(res16);   // >>> 2\n\n        long res17 = db.ListLeftPush(\"bikes:repairs\", \"bike:important_bike\");\n        Console.WriteLine(res17);   // >>> 3\n\n        RedisValue[] res18 = db.ListRange(\"bikes:repairs\", 0, -1);\n        Console.WriteLine(string.Join(\", \", res18));    // >>> \"bike:important_bike, bike:1, bike:2\"",
      "section_id": "first-steps-with-redis-lists"
    },
    {
      "id": "first-steps-with-redis-lists-ex2",
      "language": "csharp",
      "code": "db.KeyDelete(\"bikes:repairs\");\n\n        long res15 = db.ListRightPush(\"bikes:repairs\", \"bike:1\");\n        Console.WriteLine(res15);   // >>> 1\n\n        long res16 = db.ListRightPush(\"bikes:repairs\", \"bike:2\");\n        Console.WriteLine(res16);   // >>> 2\n\n        long res17 = db.ListLeftPush(\"bikes:repairs\", \"bike:important_bike\");\n        Console.WriteLine(res17);   // >>> 3\n\n        RedisValue[] res18 = db.ListRange(\"bikes:repairs\", 0, -1);\n        Console.WriteLine(string.Join(\", \", res18));    // >>> \"bike:important_bike, bike:1, bike:2\"",
      "section_id": "first-steps-with-redis-lists"
    },
    {
      "id": "first-steps-with-redis-lists-ex3",
      "language": "csharp",
      "code": "long res15 = db.ListRightPush(\"bikes:repairs\", \"bike:1\");\n        Console.WriteLine(res15);   // >>> 1\n\n        long res16 = db.ListRightPush(\"bikes:repairs\", \"bike:2\");\n        Console.WriteLine(res16);   // >>> 2\n\n        long res17 = db.ListLeftPush(\"bikes:repairs\", \"bike:important_bike\");\n        Console.WriteLine(res17);   // >>> 3\n\n        RedisValue[] res18 = db.ListRange(\"bikes:repairs\", 0, -1);\n        Console.WriteLine(string.Join(\", \", res18));    // >>> \"bike:important_bike, bike:1, bike:2\"",
      "section_id": "first-steps-with-redis-lists"
    },
    {
      "id": "first-steps-with-redis-lists-ex4",
      "language": "csharp",
      "code": "db.KeyDelete(\"bikes:repairs\");\n\n        long res15 = db.ListRightPush(\"bikes:repairs\", \"bike:1\");\n        Console.WriteLine(res15);   // >>> 1\n\n        long res16 = db.ListRightPush(\"bikes:repairs\", \"bike:2\");\n        Console.WriteLine(res16);   // >>> 2\n\n        long res17 = db.ListLeftPush(\"bikes:repairs\", \"bike:important_bike\");\n        Console.WriteLine(res17);   // >>> 3\n\n        RedisValue[] res18 = db.ListRange(\"bikes:repairs\", 0, -1);\n        Console.WriteLine(string.Join(\", \", res18));    // >>> \"bike:important_bike, bike:1, bike:2\"",
      "section_id": "first-steps-with-redis-lists"
    },
    {
      "id": "first-steps-with-redis-lists-ex5",
      "language": "go",
      "code": "rdb.Del(ctx, \"bikes:repairs\")\n\n\tres15, err := rdb.RPush(ctx, \"bikes:repairs\", \"bike:1\").Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(res15) // >>> 1\n\n\tres16, err := rdb.RPush(ctx, \"bikes:repairs\", \"bike:2\").Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(res16) // >>> 2\n\n\tres17, err := rdb.LPush(ctx, \"bikes:repairs\", \"bike:important_bike\").Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(res17) // >>> 3\n\n\tres18, err := rdb.LRange(ctx, \"bikes:repairs\", 0, -1).Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(res18) // >>> [bike:important_bike bike:1 bike:2]",
      "section_id": "first-steps-with-redis-lists"
    },
    {
      "id": "first-steps-with-redis-lists-ex6",
      "language": "java",
      "code": "CompletableFuture<Void> lpushrpush = asyncCommands.rpush(\"bikes:repairs\", \"bike:1\").thenCompose(res11 -> {\n                System.out.println(res11); // >>> 1\n\n                return asyncCommands.rpush(\"bikes:repairs\", \"bike:2\");\n            }).thenCompose(res12 -> {\n                System.out.println(res12); // >>> 2\n\n                return asyncCommands.lpush(\"bikes:repairs\", \"bike:important_bike\");\n            }).thenCompose(res13 -> {\n                System.out.println(res13); // >>> 3\n\n                return asyncCommands.lrange(\"bikes:repairs\", 0, -1);\n            })\n                    .thenAccept(System.out::println)\n                    // >>> [bike:important_bike, bike:1, bike:2]\n                    .toCompletableFuture();",
      "section_id": "first-steps-with-redis-lists"
    },
    {
      "id": "first-steps-with-redis-lists-ex7",
      "language": "java",
      "code": "jedis.del(\"bikes:repairs\");\n\n        long res15 = jedis.rpush(\"bikes:repairs\", \"bike:1\");\n        System.out.println(res15);  // >>> 1\n\n        long res16 = jedis.rpush(\"bikes:repairs\", \"bike:2\");\n        System.out.println(res16);  // >>> 2\n\n        long res17 = jedis.lpush(\"bikes:repairs\", \"bike:important_bike\");\n        System.out.println(res17);  // >>> 3\n\n        List<String> res18 = jedis.lrange(\"bikes:repairs\", 0, -1);\n        System.out.println(res18);  // >>> [bike:important_bike, bike:1, bike:2]",
      "section_id": "first-steps-with-redis-lists"
    },
    {
      "id": "first-steps-with-redis-lists-ex8",
      "language": "javascript",
      "code": "await client.del('bikes:repairs');\n\nconst res15 = await client.rPush('bikes:repairs', 'bike:1');\nconsole.log(res15);  // 1\n\nconst res16 = await client.rPush('bikes:repairs', 'bike:2');\nconsole.log(res16);  // 2\n\nconst res17 = await client.lPush('bikes:repairs', 'bike:important_bike');\nconsole.log(res17);  // 3\n\nconst res18 = await client.lRange('bikes:repairs', 0, -1);\nconsole.log(res18);  // ['bike:important_bike', 'bike:1', 'bike:2']",
      "section_id": "first-steps-with-redis-lists"
    },
    {
      "id": "first-steps-with-redis-lists-ex9",
      "language": "php",
      "code": "$r->del('bikes:repairs');\n        \n        $res15 = $r->rpush('bikes:repairs', 'bike:1');\n        echo $res15 . PHP_EOL;\n        // >>> 1\n\n        $res16 = $r->rpush('bikes:repairs', 'bike:2');\n        echo $res16 . PHP_EOL;\n        // >>> 2\n\n        $res17 = $r->lpush('bikes:repairs', 'bike:important_bike');\n        echo $res17 . PHP_EOL;\n        // >>> 3\n\n        $res18 = $r->lrange('bikes:repairs', 0, -1);\n        echo json_encode($res18) . PHP_EOL;\n        // >>> ['bike:important_bike', 'bike:1', 'bike:2']",
      "section_id": "first-steps-with-redis-lists"
    },
    {
      "id": "first-steps-with-redis-lists-ex10",
      "language": "python",
      "code": "r.delete(\"bikes:repairs\")\n\nres15 = r.rpush(\"bikes:repairs\", \"bike:1\")\nprint(res15)  # >>> 1\n\nres16 = r.rpush(\"bikes:repairs\", \"bike:2\")\nprint(res16)  # >>> 2\n\nres17 = r.lpush(\"bikes:repairs\", \"bike:important_bike\")\nprint(res17)  # >>> 3\n\nres18 = r.lrange(\"bikes:repairs\", 0, -1)\nprint(res18)  # >>> ['bike:important_bike', 'bike:1', 'bike:2']",
      "section_id": "first-steps-with-redis-lists"
    },
    {
      "id": "first-steps-with-redis-lists-ex11",
      "language": "ruby",
      "code": "r.del('bikes:repairs')\n\nres18 = r.rpush('bikes:repairs', 'bike:1')\nputs res18 # >>> 1\n\nres19 = r.rpush('bikes:repairs', 'bike:2')\nputs res19 # >>> 2\n\nres20 = r.lpush('bikes:repairs', 'bike:important_bike')\nputs res20 # >>> 3\n\nres21 = r.lrange('bikes:repairs', 0, -1)\nputs res21.inspect # >>> [\"bike:important_bike\", \"bike:1\", \"bike:2\"]",
      "section_id": "first-steps-with-redis-lists"
    },
    {
      "id": "first-steps-with-redis-lists-ex12",
      "language": "rust",
      "code": "let _: usize = r.del(\"bikes:repairs\").await.unwrap_or(0);\n\n        if let Ok(res) = r.rpush(\"bikes:repairs\", \"bike:1\").await {\n            let res: usize = res;\n            println!(\"{res}\"); // >>> 1\n        }\n\n        if let Ok(res) = r.rpush(\"bikes:repairs\", \"bike:2\").await {\n            let res: usize = res;\n            println!(\"{res}\"); // >>> 2\n        }\n\n        if let Ok(res) = r.lpush(\"bikes:repairs\", \"bike:important_bike\").await {\n            let res: usize = res;\n            println!(\"{res}\"); // >>> 3\n        }\n\n        if let Ok(res) = r.lrange(\"bikes:repairs\", 0, -1).await {\n            let res: Vec<String> = res;\n            println!(\"{res:?}\"); // >>> [\"bike:important_bike\", \"bike:1\", \"bike:2\"]\n        }",
      "section_id": "first-steps-with-redis-lists"
    },
    {
      "id": "first-steps-with-redis-lists-ex13",
      "language": "rust",
      "code": "let _: usize = r.del(\"bikes:repairs\").unwrap_or(0);\n\n        if let Ok(res) = r.rpush(\"bikes:repairs\", \"bike:1\") {\n            let res: usize = res;\n            println!(\"{res}\"); // >>> 1\n        }\n\n        if let Ok(res) = r.rpush(\"bikes:repairs\", \"bike:2\") {\n            let res: usize = res;\n            println!(\"{res}\"); // >>> 2\n        }\n\n        if let Ok(res) = r.lpush(\"bikes:repairs\", \"bike:important_bike\") {\n            let res: usize = res;\n            println!(\"{res}\"); // >>> 3\n        }\n\n        if let Ok(res) = r.lrange(\"bikes:repairs\", 0, -1) {\n            let res: Vec<String> = res;\n            println!(\"{res:?}\"); // >>> [\"bike:important_bike\", \"bike:1\", \"bike:2\"]\n        }",
      "section_id": "first-steps-with-redis-lists"
    },
    {
      "id": "first-steps-with-redis-lists-ex14",
      "language": "plaintext",
      "code": "> DEL bikes:repairs\n(integer) 1\n> RPUSH bikes:repairs bike:1 bike:2 bike:3\n(integer) 3\n> LPUSH bikes:repairs bike:important_bike bike:very_important_bike\n> LRANGE bikes:repairs 0 -1\n1) \"bike:very_important_bike\"\n2) \"bike:important_bike\"\n3) \"bike:1\"\n4) \"bike:2\"\n5) \"bike:3\"",
      "section_id": "first-steps-with-redis-lists"
    },
    {
      "id": "first-steps-with-redis-lists-ex15",
      "language": "csharp",
      "code": "long res19 = db.ListRightPush(\"bikes:repairs\", [\"bike:1\", \"bike:2\", \"bike:3\"]);\n        Console.WriteLine(res19);   // >>> 3\n\n        long res20 = db.ListLeftPush(\"bikes:repairs\", [\"bike:important_bike\", \"bike:very_important_bike\"]);\n        Console.WriteLine(res20);   // >>> 5\n\n        RedisValue[] res21 = db.ListRange(\"bikes:repairs\", 0, -1);\n        Console.WriteLine(string.Join(\", \", res21));\n        // >>> \"bike:very_important_bike, bike:important_bike, bike:1, bike:2, bike:3\"",
      "section_id": "first-steps-with-redis-lists"
    },
    {
      "id": "first-steps-with-redis-lists-ex16",
      "language": "csharp",
      "code": "db.KeyDelete(\"bikes:repairs\");\n        \n        long res19 = db.ListRightPush(\"bikes:repairs\", [\"bike:1\", \"bike:2\", \"bike:3\"]);\n        Console.WriteLine(res19);   // >>> 3\n\n        long res20 = db.ListLeftPush(\"bikes:repairs\", [\"bike:important_bike\", \"bike:very_important_bike\"]);\n        Console.WriteLine(res20);   // >>> 5\n\n        RedisValue[] res21 = db.ListRange(\"bikes:repairs\", 0, -1);\n        Console.WriteLine(string.Join(\", \", res21));\n        // >>> \"bike:very_important_bike, bike:important_bike, bike:1, bike:2, bike:3\"",
      "section_id": "first-steps-with-redis-lists"
    },
    {
      "id": "first-steps-with-redis-lists-ex17",
      "language": "csharp",
      "code": "long res19 = db.ListRightPush(\"bikes:repairs\", [\"bike:1\", \"bike:2\", \"bike:3\"]);\n        Console.WriteLine(res19);   // >>> 3\n\n        long res20 = db.ListLeftPush(\"bikes:repairs\", [\"bike:important_bike\", \"bike:very_important_bike\"]);\n        Console.WriteLine(res20);   // >>> 5\n\n        RedisValue[] res21 = db.ListRange(\"bikes:repairs\", 0, -1);\n        Console.WriteLine(string.Join(\", \", res21));\n        // >>> \"bike:very_important_bike, bike:important_bike, bike:1, bike:2, bike:3\"",
      "section_id": "first-steps-with-redis-lists"
    },
    {
      "id": "first-steps-with-redis-lists-ex18",
      "language": "csharp",
      "code": "db.KeyDelete(\"bikes:repairs\");\n        \n        long res19 = db.ListRightPush(\"bikes:repairs\", [\"bike:1\", \"bike:2\", \"bike:3\"]);\n        Console.WriteLine(res19);   // >>> 3\n\n        long res20 = db.ListLeftPush(\"bikes:repairs\", [\"bike:important_bike\", \"bike:very_important_bike\"]);\n        Console.WriteLine(res20);   // >>> 5\n\n        RedisValue[] res21 = db.ListRange(\"bikes:repairs\", 0, -1);\n        Console.WriteLine(string.Join(\", \", res21));\n        // >>> \"bike:very_important_bike, bike:important_bike, bike:1, bike:2, bike:3\"",
      "section_id": "first-steps-with-redis-lists"
    },
    {
      "id": "first-steps-with-redis-lists-ex19",
      "language": "go",
      "code": "rdb.Del(ctx, \"bikes:repairs\")\n\n\tres19, err := rdb.RPush(ctx, \"bikes:repairs\", \"bike:1\", \"bike:2\", \"bike:3\").Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(res19) // >>> 3\n\n\tres20, err := rdb.LPush(ctx, \"bikes:repairs\", \"bike:important_bike\", \"bike:very_important_bike\").Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(res20) // >>> 5\n\n\tres21, err := rdb.LRange(ctx, \"bikes:repairs\", 0, -1).Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(res21) // >>> [bike:very_important_bike bike:important_bike bike:1 bike:2 bike:3]",
      "section_id": "first-steps-with-redis-lists"
    },
    {
      "id": "first-steps-with-redis-lists-ex20",
      "language": "java",
      "code": "CompletableFuture<Void> variadic = asyncCommands.rpush(\"bikes:repairs\", \"bike:1\", \"bike:2\", \"bike:3\")\n                    .thenCompose(res14 -> {\n                        System.out.println(res14); // >>> 3\n\n                        return asyncCommands.lpush(\"bikes:repairs\", \"bike:important_bike\", \"bike:very_important_bike\");\n                    }).thenCompose(res15 -> {\n                        System.out.println(res15); // >>> 5\n\n                        return asyncCommands.lrange(\"bikes:repairs\", 0, -1);\n                    })\n                    .thenAccept(System.out::println)\n                    // >>> [bike:very_important_bike, bike:important_bike, bike:1, bike:2, bike:3]\n                    .toCompletableFuture();",
      "section_id": "first-steps-with-redis-lists"
    },
    {
      "id": "first-steps-with-redis-lists-ex21",
      "language": "java",
      "code": "jedis.del(\"bikes:repairs\");\n        \n        long res19 = jedis.rpush(\"bikes:repairs\", \"bike:1\", \"bike:2\", \"bike:3\");\n        System.out.println(res19);  // >>> 3\n\n        long res20 = jedis.lpush(\"bikes:repairs\", \"bike:important_bike\", \"bike:very_important_bike\");\n        System.out.println(res20);  // >>> 5\n\n        List<String> res21 = jedis.lrange(\"bikes:repairs\", 0, -1);\n        System.out.println(res21);  // >>> [bike:very_important_bike, bike:important_bike, bike:1, bike:2, bike:3]",
      "section_id": "first-steps-with-redis-lists"
    },
    {
      "id": "first-steps-with-redis-lists-ex22",
      "language": "javascript",
      "code": "await client.del('bikes:repairs');\n\nconst res19 = await client.rPush('bikes:repairs', ['bike:1', 'bike:2', 'bike:3']);\nconsole.log(res19);  // 3\n\nconst res20 = await client.lPush(\n  'bikes:repairs', ['bike:important_bike', 'bike:very_important_bike']\n);\nconsole.log(res20);  // 5\n\nconst res21 = await client.lRange('bikes:repairs', 0, -1);\nconsole.log(res21);  // ['bike:very_important_bike', 'bike:important_bike', 'bike:1', 'bike:2', 'bike:3']",
      "section_id": "first-steps-with-redis-lists"
    },
    {
      "id": "first-steps-with-redis-lists-ex23",
      "language": "php",
      "code": "$r->del('bikes:repairs');\n\n        $res19 = $r->rpush('bikes:repairs', 'bike:1', 'bike:2', 'bike:3');\n        echo $res19 . PHP_EOL;\n        // >>> 3\n\n        $res20 = $r->lpush('bikes:repairs', 'bike:important_bike', 'bike:very_important_bike');\n        echo $res20 . PHP_EOL;\n        // >>> 5\n\n        $res21 = $r->lrange('bikes:repairs', 0, -1);\n        echo json_encode($res21) . PHP_EOL;\n        // >>> ['bike:very_important_bike', 'bike:important_bike', 'bike:1', ...",
      "section_id": "first-steps-with-redis-lists"
    },
    {
      "id": "first-steps-with-redis-lists-ex24",
      "language": "python",
      "code": "r.delete(\"bikes:repairs\")\n\nres19 = r.rpush(\"bikes:repairs\", \"bike:1\", \"bike:2\", \"bike:3\")\nprint(res19)  # >>> 3\n\nres20 = r.lpush(\"bikes:repairs\", \"bike:important_bike\", \"bike:very_important_bike\")\nprint(res20)  # >>> 5\n\nres21 = r.lrange(\"bikes:repairs\", 0, -1)\nprint(\n    res21\n)  # >>> ['bike:very_important_bike', 'bike:important_bike', 'bike:1', ...",
      "section_id": "first-steps-with-redis-lists"
    },
    {
      "id": "first-steps-with-redis-lists-ex25",
      "language": "ruby",
      "code": "r.del('bikes:repairs')\n\nres22 = r.rpush('bikes:repairs', ['bike:1', 'bike:2', 'bike:3'])\nputs res22 # >>> 3\n\nres23 = r.lpush('bikes:repairs', ['bike:important_bike', 'bike:very_important_bike'])\nputs res23 # >>> 5\n\nres24 = r.lrange('bikes:repairs', 0, -1)\nputs res24.inspect\n# >>> [\"bike:very_important_bike\", \"bike:important_bike\", \"bike:1\", \"bike:2\", \"bike:3\"]",
      "section_id": "first-steps-with-redis-lists"
    },
    {
      "id": "first-steps-with-redis-lists-ex26",
      "language": "rust",
      "code": "let _: usize = r.del(\"bikes:repairs\").await.unwrap_or(0);\n\n        if let Ok(res) = r.rpush(\"bikes:repairs\", &[\"bike:1\", \"bike:2\", \"bike:3\"]).await {\n            let res: usize = res;\n            println!(\"{res}\"); // >>> 3\n        }\n\n        if let Ok(res) = r\n            .lpush(\"bikes:repairs\", &[\"bike:important_bike\", \"bike:very_important_bike\"])\n            .await\n        {\n            let res: usize = res;\n            println!(\"{res}\"); // >>> 5\n        }\n\n        if let Ok(res) = r.lrange(\"bikes:repairs\", 0, -1).await {\n            let res: Vec<String> = res;\n            println!(\"{res:?}\");\n            // >>> [\"bike:very_important_bike\", \"bike:important_bike\", \"bike:1\", \"bike:2\", \"bike:3\"]\n        }",
      "section_id": "first-steps-with-redis-lists"
    },
    {
      "id": "first-steps-with-redis-lists-ex27",
      "language": "rust",
      "code": "let _: usize = r.del(\"bikes:repairs\").unwrap_or(0);\n\n        if let Ok(res) = r.rpush(\"bikes:repairs\", &[\"bike:1\", \"bike:2\", \"bike:3\"]) {\n            let res: usize = res;\n            println!(\"{res}\"); // >>> 3\n        }\n\n        if let Ok(res) = r.lpush(\"bikes:repairs\", &[\"bike:important_bike\", \"bike:very_important_bike\"]) {\n            let res: usize = res;\n            println!(\"{res}\"); // >>> 5\n        }\n\n        if let Ok(res) = r.lrange(\"bikes:repairs\", 0, -1) {\n            let res: Vec<String> = res;\n            println!(\"{res:?}\");\n            // >>> [\"bike:very_important_bike\", \"bike:important_bike\", \"bike:1\", \"bike:2\", \"bike:3\"]\n        }",
      "section_id": "first-steps-with-redis-lists"
    },
    {
      "id": "first-steps-with-redis-lists-ex28",
      "language": "plaintext",
      "code": "> DEL bikes:repairs\n(integer) 1\n> RPUSH bikes:repairs bike:1 bike:2 bike:3\n(integer) 3\n> RPOP bikes:repairs\n\"bike:3\"\n> LPOP bikes:repairs\n\"bike:1\"\n> RPOP bikes:repairs\n\"bike:2\"\n> RPOP bikes:repairs\n(nil)",
      "section_id": "first-steps-with-redis-lists"
    },
    {
      "id": "first-steps-with-redis-lists-ex29",
      "language": "csharp",
      "code": "long res22 = db.ListRightPush(\"bikes:repairs\", [\"bike:1\", \"bike:2\", \"bike:3\"]);\n        Console.WriteLine(res22);   // >>> 3\n\n        RedisValue res23 = db.ListRightPop(\"bikes:repairs\");\n        Console.WriteLine(res23);   // >>> \"bike:3\"\n\n        RedisValue res24 = db.ListLeftPop(\"bikes:repairs\");\n        Console.WriteLine(res24);   // >>> \"bike:1\"\n\n        RedisValue res25 = db.ListRightPop(\"bikes:repairs\");\n        Console.WriteLine(res25);   // >>> \"bike:2\"\n\n        RedisValue res26 = db.ListRightPop(\"bikes:repairs\");\n        Console.WriteLine(res26);   // >>> <Empty string>",
      "section_id": "first-steps-with-redis-lists"
    },
    {
      "id": "first-steps-with-redis-lists-ex30",
      "language": "csharp",
      "code": "db.KeyDelete(\"bikes:repairs\");\n\n        long res22 = db.ListRightPush(\"bikes:repairs\", [\"bike:1\", \"bike:2\", \"bike:3\"]);\n        Console.WriteLine(res22);   // >>> 3\n\n        RedisValue res23 = db.ListRightPop(\"bikes:repairs\");\n        Console.WriteLine(res23);   // >>> \"bike:3\"\n\n        RedisValue res24 = db.ListLeftPop(\"bikes:repairs\");\n        Console.WriteLine(res24);   // >>> \"bike:1\"\n\n        RedisValue res25 = db.ListRightPop(\"bikes:repairs\");\n        Console.WriteLine(res25);   // >>> \"bike:2\"\n\n        RedisValue res26 = db.ListRightPop(\"bikes:repairs\");\n        Console.WriteLine(res26);   // >>> <Empty string>",
      "section_id": "first-steps-with-redis-lists"
    },
    {
      "id": "first-steps-with-redis-lists-ex31",
      "language": "csharp",
      "code": "long res22 = db.ListRightPush(\"bikes:repairs\", [\"bike:1\", \"bike:2\", \"bike:3\"]);\n        Console.WriteLine(res22);   // >>> 3\n\n        RedisValue res23 = db.ListRightPop(\"bikes:repairs\");\n        Console.WriteLine(res23);   // >>> \"bike:3\"\n\n        RedisValue res24 = db.ListLeftPop(\"bikes:repairs\");\n        Console.WriteLine(res24);   // >>> \"bike:1\"\n\n        RedisValue res25 = db.ListRightPop(\"bikes:repairs\");\n        Console.WriteLine(res25);   // >>> \"bike:2\"\n\n        RedisValue res26 = db.ListRightPop(\"bikes:repairs\");\n        Console.WriteLine(res26);   // >>> <Empty string>",
      "section_id": "first-steps-with-redis-lists"
    },
    {
      "id": "first-steps-with-redis-lists-ex32",
      "language": "csharp",
      "code": "db.KeyDelete(\"bikes:repairs\");\n\n        long res22 = db.ListRightPush(\"bikes:repairs\", [\"bike:1\", \"bike:2\", \"bike:3\"]);\n        Console.WriteLine(res22);   // >>> 3\n\n        RedisValue res23 = db.ListRightPop(\"bikes:repairs\");\n        Console.WriteLine(res23);   // >>> \"bike:3\"\n\n        RedisValue res24 = db.ListLeftPop(\"bikes:repairs\");\n        Console.WriteLine(res24);   // >>> \"bike:1\"\n\n        RedisValue res25 = db.ListRightPop(\"bikes:repairs\");\n        Console.WriteLine(res25);   // >>> \"bike:2\"\n\n        RedisValue res26 = db.ListRightPop(\"bikes:repairs\");\n        Console.WriteLine(res26);   // >>> <Empty string>",
      "section_id": "first-steps-with-redis-lists"
    },
    {
      "id": "first-steps-with-redis-lists-ex33",
      "language": "go",
      "code": "rdb.Del(ctx, \"bikes:repairs\")\n\n\tres22, err := rdb.RPush(ctx, \"bikes:repairs\", \"bike:1\", \"bike:2\", \"bike:3\").Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(res22) // >>> 3\n\n\tres23, err := rdb.RPop(ctx, \"bikes:repairs\").Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(res23) // >>> bike:3\n\n\tres24, err := rdb.LPop(ctx, \"bikes:repairs\").Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(res24) // >>> bike:1\n\n\tres25, err := rdb.RPop(ctx, \"bikes:repairs\").Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(res25) // >>> bike:2\n\n\tres26, err := rdb.RPop(ctx, \"bikes:repairs\").Result()\n\n\tif err != nil {\n\t\tfmt.Println(err) // >>> redis: nil\n\t}\n\n\tfmt.Println(res26) // >>> <empty string>",
      "section_id": "first-steps-with-redis-lists"
    },
    {
      "id": "first-steps-with-redis-lists-ex34",
      "language": "java",
      "code": "CompletableFuture<Void> lpoprpop = asyncCommands.rpush(\"bikes:repairs\", \"bike:1\", \"bike:2\", \"bike:3\")\n                    .thenCompose(res16 -> {\n                        System.out.println(res16); // >>> 3\n\n                        return asyncCommands.rpop(\"bikes:repairs\");\n                    }).thenCompose(res17 -> {\n                        System.out.println(res17); // >>> bike:3\n\n                        return asyncCommands.lpop(\"bikes:repairs\");\n                    }).thenCompose(res18 -> {\n                        System.out.println(res18); // >>> bike:1\n\n                        return asyncCommands.rpop(\"bikes:repairs\");\n                    }).thenCompose(res19 -> {\n                        System.out.println(res19); // >>> bike:2\n\n                        return asyncCommands.rpop(\"bikes:repairs\");\n                    })\n                    .thenAccept(System.out::println) // >>> null\n                    .toCompletableFuture();",
      "section_id": "first-steps-with-redis-lists"
    },
    {
      "id": "first-steps-with-redis-lists-ex35",
      "language": "java",
      "code": "jedis.del(\"bikes:repairs\");\n\n        long res22 = jedis.rpush(\"bikes:repairs\", \"bike:1\", \"bike:2\", \"bike:3\");\n        System.out.println(res22);  // >>> 3\n\n        String res23 = jedis.rpop(\"bikes:repairs\");\n        System.out.println(res23);  // >>> bike:3\n\n        String res24 = jedis.lpop(\"bikes:repairs\");\n        System.out.println(res24);  // >>> bike:1\n\n        String res25 = jedis.rpop(\"bikes:repairs\");\n        System.out.println(res25);  // >>> bike:2\n\n        String res26 = jedis.rpop(\"bikes:repairs\");\n        System.out.println(res26);  // >>> null",
      "section_id": "first-steps-with-redis-lists"
    },
    {
      "id": "first-steps-with-redis-lists-ex36",
      "language": "javascript",
      "code": "await client.del('bikes:repairs');\n\nconst res22 = await client.rPush('bikes:repairs', ['bike:1', 'bike:2', 'bike:3']);\nconsole.log(res22);  // 3\n\nconst res23 = await client.rPop('bikes:repairs');\nconsole.log(res23);  // 'bike:3'\n\nconst res24 = await client.lPop('bikes:repairs');\nconsole.log(res24);  // 'bike:1'\n\nconst res25 = await client.rPop('bikes:repairs');\nconsole.log(res25);  // 'bike:2'\n\nconst res26 = await client.rPop('bikes:repairs');\nconsole.log(res26);  // null",
      "section_id": "first-steps-with-redis-lists"
    },
    {
      "id": "first-steps-with-redis-lists-ex37",
      "language": "php",
      "code": "$r->del('bikes:repairs');\n        \n        $res22 = $r->rpush('bikes:repairs', 'bike:1', 'bike:2', 'bike:3');\n        echo $res22 . PHP_EOL;\n        // >>> 3\n\n        $res23 = $r->rpop('bikes:repairs');\n        echo $res23 . PHP_EOL;\n        // >>> 'bike:3'\n\n        $res24 = $r->lpop('bikes:repairs');\n        echo $res24 . PHP_EOL;\n        // >>> 'bike:1'\n\n        $res25 = $r->rpop('bikes:repairs');\n        echo $res25 . PHP_EOL;\n        // >>> 'bike:2'\n\n        $res26 = $r->rpop('bikes:repairs');\n        echo $res26 . PHP_EOL;\n        // >>> None",
      "section_id": "first-steps-with-redis-lists"
    },
    {
      "id": "first-steps-with-redis-lists-ex38",
      "language": "python",
      "code": "r.delete(\"bikes:repairs\")\n\nres22 = r.rpush(\"bikes:repairs\", \"bike:1\", \"bike:2\", \"bike:3\")\nprint(res22)  # >>> 3\n\nres23 = r.rpop(\"bikes:repairs\")\nprint(res23)  # >>> 'bike:3'\n\nres24 = r.lpop(\"bikes:repairs\")\nprint(res24)  # >>> 'bike:1'\n\nres25 = r.rpop(\"bikes:repairs\")\nprint(res25)  # >>> 'bike:2'\n\nres26 = r.rpop(\"bikes:repairs\")\nprint(res26)  # >>> None",
      "section_id": "first-steps-with-redis-lists"
    },
    {
      "id": "first-steps-with-redis-lists-ex39",
      "language": "ruby",
      "code": "r.del('bikes:repairs')\n\nres25 = r.rpush('bikes:repairs', ['bike:1', 'bike:2', 'bike:3'])\nputs res25 # >>> 3\n\nres26 = r.rpop('bikes:repairs')\nputs res26 # >>> bike:3\n\nres27 = r.lpop('bikes:repairs')\nputs res27 # >>> bike:1\n\nres28 = r.rpop('bikes:repairs')\nputs res28 # >>> bike:2\n\nres29 = r.rpop('bikes:repairs')\nputs res29.inspect # >>> nil",
      "section_id": "first-steps-with-redis-lists"
    },
    {
      "id": "first-steps-with-redis-lists-ex40",
      "language": "rust",
      "code": "let _: usize = r.del(\"bikes:repairs\").await.unwrap_or(0);\n\n        if let Ok(res) = r.rpush(\"bikes:repairs\", &[\"bike:1\", \"bike:2\", \"bike:3\"]).await {\n            let res: usize = res;\n            println!(\"{res}\"); // >>> 3\n        }\n\n        if let Ok(res) = r.rpop(\"bikes:repairs\", None).await {\n            let res: Option<String> = res;\n            print_optional_string(res.clone()); // >>> bike:3\n        }\n\n        if let Ok(res) = r.lpop(\"bikes:repairs\", None).await {\n            let res: Option<String> = res;\n            print_optional_string(res.clone()); // >>> bike:1\n        }\n\n        if let Ok(res) = r.rpop(\"bikes:repairs\", None).await {\n            let res: Option<String> = res;\n            print_optional_string(res.clone()); // >>> bike:2\n        }\n\n        if let Ok(res) = r.rpop(\"bikes:repairs\", None).await {\n            let res: Option<String> = res;\n            print_optional_string(res.clone()); // >>> (nil)\n        }",
      "section_id": "first-steps-with-redis-lists"
    },
    {
      "id": "first-steps-with-redis-lists-ex41",
      "language": "rust",
      "code": "let _: usize = r.del(\"bikes:repairs\").unwrap_or(0);\n\n        if let Ok(res) = r.rpush(\"bikes:repairs\", &[\"bike:1\", \"bike:2\", \"bike:3\"]) {\n            let res: usize = res;\n            println!(\"{res}\"); // >>> 3\n        }\n\n        if let Ok(res) = r.rpop(\"bikes:repairs\", None) {\n            let res: Option<String> = res;\n            print_optional_string(res.clone()); // >>> bike:3\n        }\n\n        if let Ok(res) = r.lpop(\"bikes:repairs\", None) {\n            let res: Option<String> = res;\n            print_optional_string(res.clone()); // >>> bike:1\n        }\n\n        if let Ok(res) = r.rpop(\"bikes:repairs\", None) {\n            let res: Option<String> = res;\n            print_optional_string(res.clone()); // >>> bike:2\n        }\n\n        if let Ok(res) = r.rpop(\"bikes:repairs\", None) {\n            let res: Option<String> = res;\n            print_optional_string(res.clone()); // >>> (nil)\n        }",
      "section_id": "first-steps-with-redis-lists"
    },
    {
      "id": "capped-lists-ex0",
      "language": "plaintext",
      "code": "> DEL bikes:repairs\n(integer) 0\n> RPUSH bikes:repairs bike:1 bike:2 bike:3 bike:4 bike:5\n(integer) 5\n> LTRIM bikes:repairs 0 2\nOK\n> LRANGE bikes:repairs 0 -1\n1) \"bike:1\"\n2) \"bike:2\"\n3) \"bike:3\"",
      "section_id": "capped-lists"
    },
    {
      "id": "capped-lists-ex1",
      "language": "csharp",
      "code": "long res27 = db.ListLeftPush(\"bikes:repairs\", [\"bike:1\", \"bike:2\", \"bike:3\", \"bike:4\", \"bike:5\"]);\n        Console.WriteLine(res27);   // >>> 5\n\n        db.ListTrim(\"bikes:repairs\", 0, 2);\n        RedisValue[] res28 = db.ListRange(\"bikes:repairs\", 0, -1);\n        Console.WriteLine(string.Join(\", \", res28));    // \"bike:5, bike:4, bike:3\"",
      "section_id": "capped-lists"
    },
    {
      "id": "capped-lists-ex2",
      "language": "csharp",
      "code": "long res27 = db.ListLeftPush(\"bikes:repairs\", [\"bike:1\", \"bike:2\", \"bike:3\", \"bike:4\", \"bike:5\"]);\n        Console.WriteLine(res27);   // >>> 5\n\n        db.ListTrim(\"bikes:repairs\", 0, 2);\n        RedisValue[] res28 = db.ListRange(\"bikes:repairs\", 0, -1);\n        Console.WriteLine(string.Join(\", \", res28));    // \"bike:5, bike:4, bike:3\"",
      "section_id": "capped-lists"
    },
    {
      "id": "capped-lists-ex3",
      "language": "csharp",
      "code": "long res27 = db.ListLeftPush(\"bikes:repairs\", [\"bike:1\", \"bike:2\", \"bike:3\", \"bike:4\", \"bike:5\"]);\n        Console.WriteLine(res27);   // >>> 5\n\n        db.ListTrim(\"bikes:repairs\", 0, 2);\n        RedisValue[] res28 = db.ListRange(\"bikes:repairs\", 0, -1);\n        Console.WriteLine(string.Join(\", \", res28));    // \"bike:5, bike:4, bike:3\"",
      "section_id": "capped-lists"
    },
    {
      "id": "capped-lists-ex4",
      "language": "csharp",
      "code": "long res27 = db.ListLeftPush(\"bikes:repairs\", [\"bike:1\", \"bike:2\", \"bike:3\", \"bike:4\", \"bike:5\"]);\n        Console.WriteLine(res27);   // >>> 5\n\n        db.ListTrim(\"bikes:repairs\", 0, 2);\n        RedisValue[] res28 = db.ListRange(\"bikes:repairs\", 0, -1);\n        Console.WriteLine(string.Join(\", \", res28));    // \"bike:5, bike:4, bike:3\"",
      "section_id": "capped-lists"
    },
    {
      "id": "capped-lists-ex5",
      "language": "go",
      "code": "rdb.Del(ctx, \"bikes:repairs\")\n\n\tres27, err := rdb.RPush(ctx, \"bikes:repairs\", \"bike:1\", \"bike:2\", \"bike:3\", \"bike:4\", \"bike:5\").Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(res27) // >>> 5\n\n\tres28, err := rdb.LTrim(ctx, \"bikes:repairs\", 0, 2).Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(res28) // >>> OK\n\n\tres29, err := rdb.LRange(ctx, \"bikes:repairs\", 0, -1).Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(res29) // >>> [bike:1 bike:2 bike:3]",
      "section_id": "capped-lists"
    },
    {
      "id": "capped-lists-ex6",
      "language": "java",
      "code": "CompletableFuture<Void> ltrim = asyncCommands\n                    .lpush(\"bikes:repairs\", \"bike:1\", \"bike:2\", \"bike:3\", \"bike:4\", \"bike:5\").thenCompose(res20 -> {\n                        System.out.println(res20); // >>> 5\n\n                        return asyncCommands.ltrim(\"bikes:repairs\", 0, 2);\n                    }).thenCompose(res21 -> {\n                        System.out.println(res21); // >>> OK\n\n                        return asyncCommands.lrange(\"bikes:repairs\", 0, -1);\n                    })\n                    .thenAccept(System.out::println)\n                    // >>> [bike:5, bike:4, bike:3]\n                    .toCompletableFuture();",
      "section_id": "capped-lists"
    },
    {
      "id": "capped-lists-ex7",
      "language": "java",
      "code": "long res27 = jedis.rpush(\"bikes:repairs\", \"bike:1\", \"bike:2\", \"bike:3\", \"bike:4\", \"bike:5\");\n        System.out.println(res27);  // >>> 5\n\n        String res28 = jedis.ltrim(\"bikes:repairs\", 0, 2);\n        System.out.println(res28);  // >>> OK\n\n        List<String> res29 = jedis.lrange(\"bikes:repairs\", 0, -1);\n        System.out.println(res29);  // >>> [bike:1, bike:2, bike:3]",
      "section_id": "capped-lists"
    },
    {
      "id": "capped-lists-ex8",
      "language": "javascript",
      "code": "const res27 = await client.lPush(\n  'bikes:repairs', ['bike:1', 'bike:2', 'bike:3', 'bike:4', 'bike:5']\n);\nconsole.log(res27);  // 5\n\nconst res28 = await client.lTrim('bikes:repairs', 0, 2);\nconsole.log(res28);  // OK\n\nconst res29 = await client.lRange('bikes:repairs', 0, -1);\nconsole.log(res29);  // ['bike:5', 'bike:4', 'bike:3']",
      "section_id": "capped-lists"
    },
    {
      "id": "capped-lists-ex9",
      "language": "php",
      "code": "$res27 = $r->rpush('bikes:repairs', 'bike:1', 'bike:2', 'bike:3', 'bike:4', 'bike:5');\n        echo $res27 . PHP_EOL;\n        // >>> 5\n\n        $res28 = $r->ltrim('bikes:repairs', 0, 2);\n        echo $res28 . PHP_EOL;\n        // >>> True\n\n        $res29 = $r->lrange('bikes:repairs', 0, -1);\n        echo json_encode($res29) . PHP_EOL;\n        // >>> ['bike:1', 'bike:2', 'bike:3']",
      "section_id": "capped-lists"
    },
    {
      "id": "capped-lists-ex10",
      "language": "python",
      "code": "res27 = r.rpush(\"bikes:repairs\", \"bike:1\", \"bike:2\", \"bike:3\", \"bike:4\", \"bike:5\")\nprint(res27)  # >>> 5\n\nres28 = r.ltrim(\"bikes:repairs\", 0, 2)\nprint(res28)  # >>> True\n\nres29 = r.lrange(\"bikes:repairs\", 0, -1)\nprint(res29)  # >>> ['bike:1', 'bike:2', 'bike:3']",
      "section_id": "capped-lists"
    },
    {
      "id": "capped-lists-ex11",
      "language": "ruby",
      "code": "r.del('bikes:repairs')\n\nres30 = r.rpush('bikes:repairs', ['bike:1', 'bike:2', 'bike:3', 'bike:4', 'bike:5'])\nputs res30 # >>> 5\n\nres31 = r.ltrim('bikes:repairs', 0, 2)\nputs res31 # >>> OK\n\nres32 = r.lrange('bikes:repairs', 0, -1)\nputs res32.inspect # >>> [\"bike:1\", \"bike:2\", \"bike:3\"]",
      "section_id": "capped-lists"
    },
    {
      "id": "capped-lists-ex12",
      "language": "rust",
      "code": "if let Ok(res) = r\n            .rpush(\n                \"bikes:repairs\",\n                &[\"bike:1\", \"bike:2\", \"bike:3\", \"bike:4\", \"bike:5\"],\n            )\n            .await\n        {\n            let res: usize = res;\n            println!(\"{res}\"); // >>> 5\n        }\n\n        if let Ok(res) = r.ltrim(\"bikes:repairs\", 0, 2).await {\n            let res: () = res;\n            let _ = res;\n            println!(\"OK\"); // >>> OK\n        }\n\n        if let Ok(res) = r.lrange(\"bikes:repairs\", 0, -1).await {\n            let res: Vec<String> = res;\n            println!(\"{res:?}\"); // >>> [\"bike:1\", \"bike:2\", \"bike:3\"]\n        }",
      "section_id": "capped-lists"
    },
    {
      "id": "capped-lists-ex13",
      "language": "rust",
      "code": "if let Ok(res) = r.rpush(\"bikes:repairs\", &[\"bike:1\", \"bike:2\", \"bike:3\", \"bike:4\", \"bike:5\"]) {\n            let res: usize = res;\n            println!(\"{res}\"); // >>> 5\n        }\n\n        if let Ok(res) = r.ltrim(\"bikes:repairs\", 0, 2) {\n            let res: () = res;\n            let _ = res;\n            println!(\"OK\"); // >>> OK\n        }\n\n        if let Ok(res) = r.lrange(\"bikes:repairs\", 0, -1) {\n            let res: Vec<String> = res;\n            println!(\"{res:?}\"); // >>> [\"bike:1\", \"bike:2\", \"bike:3\"]\n        }",
      "section_id": "capped-lists"
    },
    {
      "id": "capped-lists-ex14",
      "language": "plaintext",
      "code": "> DEL bikes:repairs\n(integer) 1\n> RPUSH bikes:repairs bike:1 bike:2 bike:3 bike:4 bike:5\n(integer) 5\n> LTRIM bikes:repairs -3 -1\nOK\n> LRANGE bikes:repairs 0 -1\n1) \"bike:3\"\n2) \"bike:4\"\n3) \"bike:5\"",
      "section_id": "capped-lists"
    },
    {
      "id": "capped-lists-ex15",
      "language": "csharp",
      "code": "long res29 = db.ListRightPush(\"bikes:repairs\", [\"bike:1\", \"bike:2\", \"bike:3\", \"bike:4\", \"bike:5\"]);\n        Console.WriteLine(res29);   // >>> 5\n\n        db.ListTrim(\"bikes:repairs\", -3, -1);\n        RedisValue[] res30 = db.ListRange(\"bikes:repairs\", 0, -1);\n        Console.WriteLine(string.Join(\", \", res30));    // >>> \"bike:3, bike:4, bike:5\"",
      "section_id": "capped-lists"
    },
    {
      "id": "capped-lists-ex16",
      "language": "csharp",
      "code": "db.KeyDelete(\"bikes:repairs\");\n\n        long res29 = db.ListRightPush(\"bikes:repairs\", [\"bike:1\", \"bike:2\", \"bike:3\", \"bike:4\", \"bike:5\"]);\n        Console.WriteLine(res29);   // >>> 5\n\n        db.ListTrim(\"bikes:repairs\", -3, -1);\n        RedisValue[] res30 = db.ListRange(\"bikes:repairs\", 0, -1);\n        Console.WriteLine(string.Join(\", \", res30));    // >>> \"bike:3, bike:4, bike:5\"",
      "section_id": "capped-lists"
    },
    {
      "id": "capped-lists-ex17",
      "language": "csharp",
      "code": "long res29 = db.ListRightPush(\"bikes:repairs\", [\"bike:1\", \"bike:2\", \"bike:3\", \"bike:4\", \"bike:5\"]);\n        Console.WriteLine(res29);   // >>> 5\n\n        db.ListTrim(\"bikes:repairs\", -3, -1);\n        RedisValue[] res30 = db.ListRange(\"bikes:repairs\", 0, -1);\n        Console.WriteLine(string.Join(\", \", res30));    // >>> \"bike:3, bike:4, bike:5\"",
      "section_id": "capped-lists"
    },
    {
      "id": "capped-lists-ex18",
      "language": "csharp",
      "code": "db.KeyDelete(\"bikes:repairs\");\n\n        long res29 = db.ListRightPush(\"bikes:repairs\", [\"bike:1\", \"bike:2\", \"bike:3\", \"bike:4\", \"bike:5\"]);\n        Console.WriteLine(res29);   // >>> 5\n\n        db.ListTrim(\"bikes:repairs\", -3, -1);\n        RedisValue[] res30 = db.ListRange(\"bikes:repairs\", 0, -1);\n        Console.WriteLine(string.Join(\", \", res30));    // >>> \"bike:3, bike:4, bike:5\"",
      "section_id": "capped-lists"
    },
    {
      "id": "capped-lists-ex19",
      "language": "go",
      "code": "rdb.Del(ctx, \"bikes:repairs\")\n\n\tres30, err := rdb.RPush(ctx, \"bikes:repairs\", \"bike:1\", \"bike:2\", \"bike:3\", \"bike:4\", \"bike:5\").Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(res30) // >>> 5\n\n\tres31, err := rdb.LTrim(ctx, \"bikes:repairs\", -3, -1).Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(res31) // >>> OK\n\n\tres32, err := rdb.LRange(ctx, \"bikes:repairs\", 0, -1).Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(res32) // >>> [bike:3 bike:4 bike:5]",
      "section_id": "capped-lists"
    },
    {
      "id": "capped-lists-ex20",
      "language": "java",
      "code": "CompletableFuture<Void> ltrimendoflist = asyncCommands\n                    .rpush(\"bikes:repairs\", \"bike:1\", \"bike:2\", \"bike:3\", \"bike:4\", \"bike:5\").thenCompose(res22 -> {\n                        System.out.println(res22); // >>> 5\n\n                        return asyncCommands.ltrim(\"bikes:repairs\", -3, -1);\n                    }).thenCompose(res23 -> {\n                        System.out.println(res23); // >>> OK\n\n                        return asyncCommands.lrange(\"bikes:repairs\", 0, -1);\n                    })\n                    .thenAccept(System.out::println)\n                    // >>> [bike:3, bike:4, bike:5]\n                    .toCompletableFuture();",
      "section_id": "capped-lists"
    },
    {
      "id": "capped-lists-ex21",
      "language": "java",
      "code": "jedis.del(\"bikes:repairs\");\n        \n        res27 = jedis.rpush(\"bikes:repairs\", \"bike:1\", \"bike:2\", \"bike:3\", \"bike:4\", \"bike:5\");\n        System.out.println(res27);  // >>> 5\n\n        res28 = jedis.ltrim(\"bikes:repairs\", -3, -1);\n        System.out.println(res2);  // >>> OK\n\n        res29 = jedis.lrange(\"bikes:repairs\", 0, -1);\n        System.out.println(res29);  // >>> [bike:3, bike:4, bike:5]",
      "section_id": "capped-lists"
    },
    {
      "id": "capped-lists-ex22",
      "language": "javascript",
      "code": "await client.del('bikes:repairs');\n\nconst res27eol = await client.rPush(\n  'bikes:repairs', ['bike:1', 'bike:2', 'bike:3', 'bike:4', 'bike:5']\n);\nconsole.log(res27eol);  // 5\n\nconst res28eol = await client.lTrim('bikes:repairs', -3, -1);\nconsole.log(res28eol);  // 'OK'\n\nconst res29eol = await client.lRange('bikes:repairs', 0, -1);\nconsole.log(res29eol);  // ['bike:3', 'bike:4', 'bike:5']",
      "section_id": "capped-lists"
    },
    {
      "id": "capped-lists-ex23",
      "language": "php",
      "code": "$r->del('bikes:repairs');\n\n        $res27 = $r->rpush('bikes:repairs', 'bike:1', 'bike:2', 'bike:3', 'bike:4', 'bike:5');\n        echo $res27 . PHP_EOL;\n        // >>> 5\n\n        $res28 = $r->ltrim('bikes:repairs', -3, -1);\n        echo $res28 . PHP_EOL;\n        // >>> True\n\n        $res29 = $r->lrange('bikes:repairs', 0, -1);\n        echo json_encode($res29) . PHP_EOL;\n        // >>> ['bike:3', 'bike:4', 'bike:5']",
      "section_id": "capped-lists"
    },
    {
      "id": "capped-lists-ex24",
      "language": "python",
      "code": "r.delete(\"bikes:repairs\")\n\nres27 = r.rpush(\"bikes:repairs\", \"bike:1\", \"bike:2\", \"bike:3\", \"bike:4\", \"bike:5\")\nprint(res27)  # >>> 5\n\nres28 = r.ltrim(\"bikes:repairs\", -3, -1)\nprint(res28)  # >>> True\n\nres29 = r.lrange(\"bikes:repairs\", 0, -1)\nprint(res29)  # >>> ['bike:3', 'bike:4', 'bike:5']",
      "section_id": "capped-lists"
    },
    {
      "id": "capped-lists-ex25",
      "language": "ruby",
      "code": "r.del('bikes:repairs')\n\nres33 = r.rpush('bikes:repairs', ['bike:1', 'bike:2', 'bike:3', 'bike:4', 'bike:5'])\nputs res33 # >>> 5\n\nres34 = r.ltrim('bikes:repairs', -3, -1)\nputs res34 # >>> OK\n\nres35 = r.lrange('bikes:repairs', 0, -1)\nputs res35.inspect # >>> [\"bike:3\", \"bike:4\", \"bike:5\"]",
      "section_id": "capped-lists"
    },
    {
      "id": "capped-lists-ex26",
      "language": "rust",
      "code": "let _: usize = r.del(\"bikes:repairs\").await.unwrap_or(0);\n\n        if let Ok(res) = r\n            .rpush(\n                \"bikes:repairs\",\n                &[\"bike:1\", \"bike:2\", \"bike:3\", \"bike:4\", \"bike:5\"],\n            )\n            .await\n        {\n            let res: usize = res;\n            println!(\"{res}\"); // >>> 5\n        }\n\n        if let Ok(res) = r.ltrim(\"bikes:repairs\", -3, -1).await {\n            let res: () = res;\n            let _ = res;\n            println!(\"OK\"); // >>> OK\n        }\n\n        if let Ok(res) = r.lrange(\"bikes:repairs\", 0, -1).await {\n            let res: Vec<String> = res;\n            println!(\"{res:?}\"); // >>> [\"bike:3\", \"bike:4\", \"bike:5\"]\n        }",
      "section_id": "capped-lists"
    },
    {
      "id": "capped-lists-ex27",
      "language": "rust",
      "code": "let _: usize = r.del(\"bikes:repairs\").unwrap_or(0);\n\n        if let Ok(res) = r.rpush(\"bikes:repairs\", &[\"bike:1\", \"bike:2\", \"bike:3\", \"bike:4\", \"bike:5\"]) {\n            let res: usize = res;\n            println!(\"{res}\"); // >>> 5\n        }\n\n        if let Ok(res) = r.ltrim(\"bikes:repairs\", -3, -1) {\n            let res: () = res;\n            let _ = res;\n            println!(\"OK\"); // >>> OK\n        }\n\n        if let Ok(res) = r.lrange(\"bikes:repairs\", 0, -1) {\n            let res: Vec<String> = res;\n            println!(\"{res:?}\"); // >>> [\"bike:3\", \"bike:4\", \"bike:5\"]\n        }",
      "section_id": "capped-lists"
    },
    {
      "id": "blocking-operations-on-lists-ex0",
      "language": "plaintext",
      "code": "> DEL bikes:repairs\n(integer) 1\n> RPUSH bikes:repairs bike:1 bike:2\n(integer) 2\n> BRPOP bikes:repairs 1\n1) \"bikes:repairs\"\n2) \"bike:2\"\n> BRPOP bikes:repairs 1\n1) \"bikes:repairs\"\n2) \"bike:1\"\n> BRPOP bikes:repairs 1\n(nil)\n(2.01s)",
      "section_id": "blocking-operations-on-lists"
    },
    {
      "id": "blocking-operations-on-lists-ex1",
      "language": "csharp",
      "code": "long res31 = db.ListRightPush(\"bikes:repairs\", [\"bike:1\", \"bike:2\"]);\n        Console.WriteLine(res31);   // >>> 2\n\n        Tuple<RedisKey, RedisValue>? res32 = db.BRPop([\"bikes:repairs\"], 1);\n\n        if (res32 != null)\n            Console.WriteLine($\"{res32.Item1} -> {res32.Item2}\"); // >>> \"bikes:repairs -> bike:2\"\n\n        Tuple<RedisKey, RedisValue>? res33 = db.BRPop([\"bikes:repairs\"], 1);\n\n        if (res33 != null)\n            Console.WriteLine($\"{res33.Item1} -> {res33.Item2}\"); // >>> \"bikes:repairs -> bike:1\"\n\n        Tuple<RedisKey, RedisValue>? res34 = db.BRPop([\"bikes:repairs\"], 1);\n        Console.WriteLine(res34);   // >>> \"Null\"",
      "section_id": "blocking-operations-on-lists"
    },
    {
      "id": "blocking-operations-on-lists-ex2",
      "language": "csharp",
      "code": "db.KeyDelete(\"bikes:repairs\");\n\n        long res31 = db.ListRightPush(\"bikes:repairs\", [\"bike:1\", \"bike:2\"]);\n        Console.WriteLine(res31);   // >>> 2\n\n        Tuple<RedisKey, RedisValue>? res32 = db.BRPop([\"bikes:repairs\"], 1);\n\n        if (res32 != null)\n            Console.WriteLine($\"{res32.Item1} -> {res32.Item2}\"); // >>> \"bikes:repairs -> bike:2\"\n\n        Tuple<RedisKey, RedisValue>? res33 = db.BRPop([\"bikes:repairs\"], 1);\n\n        if (res33 != null)\n            Console.WriteLine($\"{res33.Item1} -> {res33.Item2}\"); // >>> \"bikes:repairs -> bike:1\"\n\n        Tuple<RedisKey, RedisValue>? res34 = db.BRPop([\"bikes:repairs\"], 1);\n        Console.WriteLine(res34);   // >>> \"Null\"",
      "section_id": "blocking-operations-on-lists"
    },
    {
      "id": "blocking-operations-on-lists-ex3",
      "language": "csharp",
      "code": "long res31 = db.ListRightPush(\"bikes:repairs\", [\"bike:1\", \"bike:2\"]);\n        Console.WriteLine(res31);   // >>> 2\n\n        Tuple<RedisKey, RedisValue>? res32 = db.BRPop([\"bikes:repairs\"], 1);\n\n        if (res32 != null)\n            Console.WriteLine($\"{res32.Item1} -> {res32.Item2}\"); // >>> \"bikes:repairs -> bike:2\"\n\n        Tuple<RedisKey, RedisValue>? res33 = db.BRPop([\"bikes:repairs\"], 1);\n\n        if (res33 != null)\n            Console.WriteLine($\"{res33.Item1} -> {res33.Item2}\"); // >>> \"bikes:repairs -> bike:1\"\n\n        Tuple<RedisKey, RedisValue>? res34 = db.BRPop([\"bikes:repairs\"], 1);\n        Console.WriteLine(res34);   // >>> \"Null\"",
      "section_id": "blocking-operations-on-lists"
    },
    {
      "id": "blocking-operations-on-lists-ex4",
      "language": "csharp",
      "code": "db.KeyDelete(\"bikes:repairs\");\n\n        long res31 = db.ListRightPush(\"bikes:repairs\", [\"bike:1\", \"bike:2\"]);\n        Console.WriteLine(res31);   // >>> 2\n\n        Tuple<RedisKey, RedisValue>? res32 = db.BRPop([\"bikes:repairs\"], 1);\n\n        if (res32 != null)\n            Console.WriteLine($\"{res32.Item1} -> {res32.Item2}\"); // >>> \"bikes:repairs -> bike:2\"\n\n        Tuple<RedisKey, RedisValue>? res33 = db.BRPop([\"bikes:repairs\"], 1);\n\n        if (res33 != null)\n            Console.WriteLine($\"{res33.Item1} -> {res33.Item2}\"); // >>> \"bikes:repairs -> bike:1\"\n\n        Tuple<RedisKey, RedisValue>? res34 = db.BRPop([\"bikes:repairs\"], 1);\n        Console.WriteLine(res34);   // >>> \"Null\"",
      "section_id": "blocking-operations-on-lists"
    },
    {
      "id": "blocking-operations-on-lists-ex5",
      "language": "go",
      "code": "rdb.Del(ctx, \"bikes:repairs\")\n\n\tres33, err := rdb.RPush(ctx, \"bikes:repairs\", \"bike:1\", \"bike:2\").Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(res33) // >>> 2\n\n\tres34, err := rdb.BRPop(ctx, 1, \"bikes:repairs\").Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(res34) // >>> [bikes:repairs bike:2]\n\n\tres35, err := rdb.BRPop(ctx, 1, \"bikes:repairs\").Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(res35) // >>> [bikes:repairs bike:1]\n\n\tres36, err := rdb.BRPop(ctx, 1, \"bikes:repairs\").Result()\n\n\tif err != nil {\n\t\tfmt.Println(err) // >>> redis: nil\n\t}\n\n\tfmt.Println(res36) // >>> []",
      "section_id": "blocking-operations-on-lists"
    },
    {
      "id": "blocking-operations-on-lists-ex6",
      "language": "java",
      "code": "CompletableFuture<Void> brpop = asyncCommands.rpush(\"bikes:repairs\", \"bike:1\", \"bike:2\").thenCompose(res24 -> {\n                System.out.println(res24); // >>> 2\n\n                return asyncCommands.brpop(1, \"bikes:repairs\");\n            }).thenCompose(res25 -> {\n                System.out.println(res25);\n                // >>> KeyValue[bikes:repairs, bike:2]\n\n                return asyncCommands.brpop(1, \"bikes:repairs\");\n            }).thenCompose(res26 -> {\n                System.out.println(res26);\n                // >>> KeyValue[bikes:repairs, bike:1]\n\n                return asyncCommands.brpop(1, \"bikes:repairs\");\n            })\n                    .thenAccept(System.out::println) // >>> null\n                    .toCompletableFuture();",
      "section_id": "blocking-operations-on-lists"
    },
    {
      "id": "blocking-operations-on-lists-ex7",
      "language": "java",
      "code": "jedis.del(\"bikes:repairs\");\n\n        long res31 = jedis.rpush(\"bikes:repairs\", \"bike:1\", \"bike:2\");\n        System.out.println(res31);  // >>> 2\n\n        List<String> res32 = jedis.brpop(1, \"bikes:repairs\");\n        System.out.println(res32);  // >>> (bikes:repairs, bike:2)\n\n        List<String>  res33 = jedis.brpop(1,\"bikes:repairs\");\n        System.out.println(res33);  // >>> (bikes:repairs, bike:1)\n\n        List<String>  res34 = jedis.brpop(1,\"bikes:repairs\");\n        System.out.println(res34);  // >>> null",
      "section_id": "blocking-operations-on-lists"
    },
    {
      "id": "blocking-operations-on-lists-ex8",
      "language": "javascript",
      "code": "await client.del('bikes:repairs');\n\nconst res31 = await client.rPush('bikes:repairs', ['bike:1', 'bike:2']);\nconsole.log(res31);  // 2\n\nconst res32 = await client.brPop('bikes:repairs', 1);\nconsole.log(res32);  // { key: 'bikes:repairs', element: 'bike:2' }\n\nconst res33 = await client.brPop('bikes:repairs', 1);\nconsole.log(res33);  // { key: 'bikes:repairs', element: 'bike:1' }\n\nconst res34 = await client.brPop('bikes:repairs', 1);\nconsole.log(res34);  // null",
      "section_id": "blocking-operations-on-lists"
    },
    {
      "id": "blocking-operations-on-lists-ex9",
      "language": "php",
      "code": "$r->del('bikes:repairs');\n\n        $res31 = $r->rpush('bikes:repairs', 'bike:1', 'bike:2');\n        echo $res31 . PHP_EOL;\n        // >>> 2\n\n        $res32 = $r->brpop('bikes:repairs', 1);\n        echo json_encode($res32) . PHP_EOL;\n        // >>> ['bikes:repairs', 'bike:2']\n\n        $res33 = $r->brpop('bikes:repairs', 1);\n        echo json_encode($res33) . PHP_EOL;\n        // >>> ['bikes:repairs', 'bike:1']\n\n        $res34 = $r->brpop('bikes:repairs', 1);\n        echo json_encode($res34) . PHP_EOL;\n        // >>> None",
      "section_id": "blocking-operations-on-lists"
    },
    {
      "id": "blocking-operations-on-lists-ex10",
      "language": "python",
      "code": "r.delete(\"bikes:repairs\")\n\nres31 = r.rpush(\"bikes:repairs\", \"bike:1\", \"bike:2\")\nprint(res31)  # >>> 2\n\nres32 = r.brpop(\"bikes:repairs\", timeout=1)\nprint(res32)  # >>> ('bikes:repairs', 'bike:2')\n\nres33 = r.brpop(\"bikes:repairs\", timeout=1)\nprint(res33)  # >>> ('bikes:repairs', 'bike:1')\n\nres34 = r.brpop(\"bikes:repairs\", timeout=1)\nprint(res34)  # >>> None",
      "section_id": "blocking-operations-on-lists"
    },
    {
      "id": "blocking-operations-on-lists-ex11",
      "language": "ruby",
      "code": "r.del('bikes:repairs')\n\nres36 = r.rpush('bikes:repairs', ['bike:1', 'bike:2'])\nputs res36 # >>> 2\n\nres37 = r.brpop('bikes:repairs', timeout: 1)\nputs res37.inspect # >>> [\"bikes:repairs\", \"bike:2\"]\n\nres38 = r.brpop('bikes:repairs', timeout: 1)\nputs res38.inspect # >>> [\"bikes:repairs\", \"bike:1\"]\n\nres39 = r.brpop('bikes:repairs', timeout: 1)\nputs res39.inspect # >>> nil",
      "section_id": "blocking-operations-on-lists"
    },
    {
      "id": "blocking-operations-on-lists-ex12",
      "language": "rust",
      "code": "let _: usize = r.del(\"bikes:repairs\").await.unwrap_or(0);\n\n        if let Ok(res) = r.rpush(\"bikes:repairs\", &[\"bike:1\", \"bike:2\"]).await {\n            let res: usize = res;\n            println!(\"{res}\"); // >>> 2\n        }\n\n        if let Ok(res) = r.brpop(\"bikes:repairs\", 1.0).await {\n            let res: Option<[String; 2]> = res;\n            println!(\"{res:?}\"); // >>> Some([\"bikes:repairs\", \"bike:2\"])\n        }\n\n        if let Ok(res) = r.brpop(\"bikes:repairs\", 1.0).await {\n            let res: Option<[String; 2]> = res;\n            println!(\"{res:?}\"); // >>> Some([\"bikes:repairs\", \"bike:1\"])\n        }\n\n        if let Ok(res) = r.brpop(\"bikes:repairs\", 1.0).await {\n            let res: Option<[String; 2]> = res;\n            println!(\"{res:?}\"); // >>> None\n        }",
      "section_id": "blocking-operations-on-lists"
    },
    {
      "id": "blocking-operations-on-lists-ex13",
      "language": "rust",
      "code": "let _: usize = r.del(\"bikes:repairs\").unwrap_or(0);\n\n        if let Ok(res) = r.rpush(\"bikes:repairs\", &[\"bike:1\", \"bike:2\"]) {\n            let res: usize = res;\n            println!(\"{res}\"); // >>> 2\n        }\n\n        if let Ok(res) = r.brpop(\"bikes:repairs\", 1.0) {\n            let res: Option<[String; 2]> = res;\n            println!(\"{res:?}\"); // >>> Some([\"bikes:repairs\", \"bike:2\"])\n        }\n\n        if let Ok(res) = r.brpop(\"bikes:repairs\", 1.0) {\n            let res: Option<[String; 2]> = res;\n            println!(\"{res:?}\"); // >>> Some([\"bikes:repairs\", \"bike:1\"])\n        }\n\n        if let Ok(res) = r.brpop(\"bikes:repairs\", 1.0) {\n            let res: Option<[String; 2]> = res;\n            println!(\"{res:?}\"); // >>> None\n        }",
      "section_id": "blocking-operations-on-lists"
    },
    {
      "id": "automatic-creation-and-removal-of-keys-ex0",
      "language": "plaintext",
      "code": "> DEL new_bikes\n(integer) 0\n> LPUSH new_bikes bike:1 bike:2 bike:3\n(integer) 3",
      "section_id": "automatic-creation-and-removal-of-keys"
    },
    {
      "id": "automatic-creation-and-removal-of-keys-ex1",
      "language": "csharp",
      "code": "bool res35 = db.KeyDelete(\"new_bikes\");\n        Console.WriteLine(res35);   // >>> False\n\n        long res36 = db.ListRightPush(\"new_bikes\", [\"bike:1\", \"bike:2\", \"bike:3\"]);\n        Console.WriteLine(res36);   // >>> 3",
      "section_id": "automatic-creation-and-removal-of-keys"
    },
    {
      "id": "automatic-creation-and-removal-of-keys-ex2",
      "language": "csharp",
      "code": "db.KeyDelete(\"new_bikes\");\n\n        long res36 = db.ListRightPush(\"new_bikes\", [\"bike:1\", \"bike:2\", \"bike:3\"]);\n        Console.WriteLine(res36);   // >>> 3",
      "section_id": "automatic-creation-and-removal-of-keys"
    },
    {
      "id": "automatic-creation-and-removal-of-keys-ex3",
      "language": "csharp",
      "code": "bool res35 = db.KeyDelete(\"new_bikes\");\n        Console.WriteLine(res35);   // >>> False\n\n        long res36 = db.ListRightPush(\"new_bikes\", [\"bike:1\", \"bike:2\", \"bike:3\"]);\n        Console.WriteLine(res36);   // >>> 3",
      "section_id": "automatic-creation-and-removal-of-keys"
    },
    {
      "id": "automatic-creation-and-removal-of-keys-ex4",
      "language": "csharp",
      "code": "db.KeyDelete(\"new_bikes\");\n\n        long res36 = db.ListRightPush(\"new_bikes\", [\"bike:1\", \"bike:2\", \"bike:3\"]);\n        Console.WriteLine(res36);   // >>> 3",
      "section_id": "automatic-creation-and-removal-of-keys"
    },
    {
      "id": "automatic-creation-and-removal-of-keys-ex5",
      "language": "go",
      "code": "res37, err := rdb.Del(ctx, \"new_bikes\").Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(res37) // >>> 0\n\n\tres38, err := rdb.LPush(ctx, \"new_bikes\", \"bike:1\", \"bike:2\", \"bike:3\").Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(res38) // >>> 3",
      "section_id": "automatic-creation-and-removal-of-keys"
    },
    {
      "id": "automatic-creation-and-removal-of-keys-ex6",
      "language": "java",
      "code": "CompletableFuture<Void> rule1 = asyncCommands.del(\"new_bikes\").thenCompose(res27 -> {\n                System.out.println(res27); // >>> 0\n\n                return asyncCommands.lpush(\"new_bikes\", \"bike:1\", \"bike:2\", \"bike:3\");\n            })\n                    .thenAccept(System.out::println) // >>> 3\n                    .toCompletableFuture();",
      "section_id": "automatic-creation-and-removal-of-keys"
    },
    {
      "id": "automatic-creation-and-removal-of-keys-ex7",
      "language": "java",
      "code": "jedis.del(\"new_bikes\");\n\n        long res36 = jedis.lpush(\"new_bikes\", \"bike:1\", \"bike:2\", \"bike:3\");\n        System.out.println(res36);  // >>> 3",
      "section_id": "automatic-creation-and-removal-of-keys"
    },
    {
      "id": "automatic-creation-and-removal-of-keys-ex8",
      "language": "javascript",
      "code": "const res35 = await client.del('new_bikes');\nconsole.log(res35); // 0\n\nconst res36 = await client.lPush('new_bikes', ['bike:1', 'bike:2', 'bike:3']);\nconsole.log(res36); // 3",
      "section_id": "automatic-creation-and-removal-of-keys"
    },
    {
      "id": "automatic-creation-and-removal-of-keys-ex9",
      "language": "php",
      "code": "$res35 = $r->del('new_bikes');\n        echo $res35 . PHP_EOL;\n        // >>> 0\n\n        $res36 = $r->lpush('new_bikes', 'bike:1', 'bike:2', 'bike:3');\n        echo $res36 . PHP_EOL;\n        // >>> 3",
      "section_id": "automatic-creation-and-removal-of-keys"
    },
    {
      "id": "automatic-creation-and-removal-of-keys-ex10",
      "language": "python",
      "code": "res35 = r.delete(\"new_bikes\")\nprint(res35)  # >>> 0\n\nres36 = r.lpush(\"new_bikes\", \"bike:1\", \"bike:2\", \"bike:3\")\nprint(res36)  # >>> 3",
      "section_id": "automatic-creation-and-removal-of-keys"
    },
    {
      "id": "automatic-creation-and-removal-of-keys-ex11",
      "language": "ruby",
      "code": "res40 = r.del('new_bikes')\nputs res40 # >>> 0\n\nres41 = r.lpush('new_bikes', ['bike:1', 'bike:2', 'bike:3'])\nputs res41 # >>> 3",
      "section_id": "automatic-creation-and-removal-of-keys"
    },
    {
      "id": "automatic-creation-and-removal-of-keys-ex12",
      "language": "rust",
      "code": "if let Ok(res) = r.del(\"new_bikes\").await {\n            let res: usize = res;\n            println!(\"{res}\"); // >>> 0\n        }\n\n        if let Ok(res) = r.lpush(\"new_bikes\", &[\"bike:1\", \"bike:2\", \"bike:3\"]).await {\n            let res: usize = res;\n            println!(\"{res}\"); // >>> 3\n        }",
      "section_id": "automatic-creation-and-removal-of-keys"
    },
    {
      "id": "automatic-creation-and-removal-of-keys-ex13",
      "language": "rust",
      "code": "if let Ok(res) = r.del(\"new_bikes\") {\n            let res: usize = res;\n            println!(\"{res}\"); // >>> 0\n        }\n\n        if let Ok(res) = r.lpush(\"new_bikes\", &[\"bike:1\", \"bike:2\", \"bike:3\"]) {\n            let res: usize = res;\n            println!(\"{res}\"); // >>> 3\n        }",
      "section_id": "automatic-creation-and-removal-of-keys"
    },
    {
      "id": "automatic-creation-and-removal-of-keys-ex14",
      "language": "plaintext",
      "code": "> DEL new_bikes\n(integer) 1\n> SET new_bikes bike:1\nOK\n> TYPE new_bikes\nstring\n> LPUSH new_bikes bike:2 bike:3\n(error) WRONGTYPE Operation against a key holding the wrong kind of value",
      "section_id": "automatic-creation-and-removal-of-keys"
    },
    {
      "id": "automatic-creation-and-removal-of-keys-ex15",
      "language": "csharp",
      "code": "bool res37 = db.StringSet(\"new_bikes\", \"bike:1\");\n        Console.WriteLine(res37);   // >>> True\n\n        RedisType res38 = db.KeyType(\"new_bikes\");\n        Console.WriteLine(res38);   // >>> RedisType.String\n\n        try\n        {\n            long res39 = db.ListRightPush(\"new_bikes\", [\"bike:2\", \"bike:3\"]);\n        }\n        catch (Exception e)\n        {\n            Console.WriteLine(e);\n        }",
      "section_id": "automatic-creation-and-removal-of-keys"
    },
    {
      "id": "automatic-creation-and-removal-of-keys-ex16",
      "language": "csharp",
      "code": "db.KeyDelete(\"new_bikes\");\n        \n        bool res37 = db.StringSet(\"new_bikes\", \"bike:1\");\n        Console.WriteLine(res37);   // >>> True\n\n        RedisType res38 = db.KeyType(\"new_bikes\");\n        Console.WriteLine(res38);   // >>> RedisType.String\n\n        try\n        {\n            long res39 = db.ListRightPush(\"new_bikes\", [\"bike:2\", \"bike:3\"]);\n        }\n        catch (Exception e)\n        {\n            Console.WriteLine(e);\n        }",
      "section_id": "automatic-creation-and-removal-of-keys"
    },
    {
      "id": "automatic-creation-and-removal-of-keys-ex17",
      "language": "csharp",
      "code": "bool res37 = db.StringSet(\"new_bikes\", \"bike:1\");\n        Console.WriteLine(res37);   // >>> True\n\n        RedisType res38 = db.KeyType(\"new_bikes\");\n        Console.WriteLine(res38);   // >>> RedisType.String\n\n        try\n        {\n            long res39 = db.ListRightPush(\"new_bikes\", [\"bike:2\", \"bike:3\"]);\n        }\n        catch (Exception e)\n        {\n            Console.WriteLine(e);\n        }",
      "section_id": "automatic-creation-and-removal-of-keys"
    },
    {
      "id": "automatic-creation-and-removal-of-keys-ex18",
      "language": "csharp",
      "code": "db.KeyDelete(\"new_bikes\");\n        \n        bool res37 = db.StringSet(\"new_bikes\", \"bike:1\");\n        Console.WriteLine(res37);   // >>> True\n\n        RedisType res38 = db.KeyType(\"new_bikes\");\n        Console.WriteLine(res38);   // >>> RedisType.String\n\n        try\n        {\n            long res39 = db.ListRightPush(\"new_bikes\", [\"bike:2\", \"bike:3\"]);\n        }\n        catch (Exception e)\n        {\n            Console.WriteLine(e);\n        }",
      "section_id": "automatic-creation-and-removal-of-keys"
    },
    {
      "id": "automatic-creation-and-removal-of-keys-ex19",
      "language": "go",
      "code": "rdb.Del(ctx, \"new_bikes\")\n\n\tres39, err := rdb.Set(ctx, \"new_bikes\", \"bike:1\", 0).Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(res39) // >>> OK\n\n\tres40, err := rdb.Type(ctx, \"new_bikes\").Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(res40) // >>> string\n\n\tres41, err := rdb.LPush(ctx, \"new_bikes\", \"bike:2\", \"bike:3\").Result()\n\n\tif err != nil {\n\t\tfmt.Println(err)\n\t\t// >>> WRONGTYPE Operation against a key holding the wrong kind of value\n\t}\n\n\tfmt.Println(res41)",
      "section_id": "automatic-creation-and-removal-of-keys"
    },
    {
      "id": "automatic-creation-and-removal-of-keys-ex20",
      "language": "java",
      "code": "CompletableFuture<Void> rule11 = asyncCommands.set(\"new_bikes_string\", \"bike:1\").thenCompose(res28 -> {\n                System.out.println(res28); // >>> OK\n\n                return asyncCommands.type(\"new_bikes_string\");\n            }).thenCompose(res29 -> {\n                System.out.println(res29); // >>> string\n\n                return asyncCommands.lpush(\"new_bikes_string\", \"bike:2\", \"bike:3\");\n            }).handle((res, ex) -> {\n                if (ex == null) {\n                    return res;\n                } else {\n                    System.out.println(ex);\n                    // >>> java.util.concurrent.CompletionException:\n                    // >>> io.lettuce.core.RedisCommandExecutionException:\n                    // >>> WRONGTYPE Operation against a key holding the wrong\n                    // >>> kind of value\n\n                    return -1L;\n                }\n            })\n                    .thenAccept(System.out::println) // >>> -1\n                    .toCompletableFuture();",
      "section_id": "automatic-creation-and-removal-of-keys"
    },
    {
      "id": "automatic-creation-and-removal-of-keys-ex21",
      "language": "java",
      "code": "jedis.del(\"new_bikes\");\n        \n        String res37 = jedis.set(\"new_bikes\", \"bike:1\");\n        System.out.println(res37);  // >>> OK\n\n        String res38 = jedis.type(\"new_bikes\");\n        System.out.println(res38);  // >>> string\n\n        try {\n            long res39  = jedis.lpush(\"new_bikes\", \"bike:2\", \"bike:3\");\n        } catch (Exception e) {\n            e.printStackTrace();\n            // >>> redis.clients.jedis.exceptions.JedisDataException:\n            // >>> WRONGTYPE Operation against a key holding the wrong kind of value\n        }",
      "section_id": "automatic-creation-and-removal-of-keys"
    },
    {
      "id": "automatic-creation-and-removal-of-keys-ex22",
      "language": "javascript",
      "code": "await client.del('new_bikes');\n\nconst res37 = await client.set('new_bikes', 'bike:1');\nconsole.log(res37);  // 'OK'\n\nconst res38 = await client.type('new_bikes');\nconsole.log(res38);  // 'string'\n\ntry {\n  const res39 = await client.lPush('new_bikes', 'bike:2', 'bike:3');\n  // redis.exceptions.ResponseError:\n  // [SimpleError: WRONGTYPE Operation against a key holding the wrong kind of value]\n}\ncatch(e){\n  console.log(e);\n}",
      "section_id": "automatic-creation-and-removal-of-keys"
    },
    {
      "id": "automatic-creation-and-removal-of-keys-ex23",
      "language": "php",
      "code": "$r->del('new_bikes');\n\n        $res37 = $r->set('new_bikes', 'bike:1');\n        echo $res37 . PHP_EOL;\n        // >>> True\n\n        $res38 = $r->type('new_bikes');\n        echo $res38 . PHP_EOL;\n        // >>> 'string'\n\n        try {\n            $res39 = $r->lpush('new_bikes', 'bike:2', 'bike:3');\n            // >>> redis.exceptions.ResponseError:\n            // >>> WRONGTYPE Operation against a key holding the wrong kind of value\n        } catch (\\Predis\\Response\\ServerException $e) {\n            echo $e->getMessage() . PHP_EOL;\n        }",
      "section_id": "automatic-creation-and-removal-of-keys"
    },
    {
      "id": "automatic-creation-and-removal-of-keys-ex24",
      "language": "python",
      "code": "r.delete(\"new_bikes\")\n\nres37 = r.set(\"new_bikes\", \"bike:1\")\nprint(res37)  # >>> True\n\nres38 = r.type(\"new_bikes\")\nprint(res38)  # >>> 'string'\n\ntry:\n    res39 = r.lpush(\"new_bikes\", \"bike:2\", \"bike:3\")\n    # >>> redis.exceptions.ResponseError:\n    # >>> WRONGTYPE Operation against a key holding the wrong kind of value\nexcept redis.exceptions.ResponseError as e:\n    print(e)",
      "section_id": "automatic-creation-and-removal-of-keys"
    },
    {
      "id": "automatic-creation-and-removal-of-keys-ex25",
      "language": "ruby",
      "code": "r.del('new_bikes')\n\nres42 = r.set('new_bikes', 'bike:1')\nputs res42 # >>> OK\n\nres43 = r.type('new_bikes')\nputs res43 # >>> string\n\nwrong_type_error = nil\nbegin\n  r.lpush('new_bikes', ['bike:2', 'bike:3'])\nrescue Redis::CommandError => e\n  wrong_type_error = e\n  puts e.message # >>> WRONGTYPE Operation against a key holding the wrong kind of value\nend",
      "section_id": "automatic-creation-and-removal-of-keys"
    },
    {
      "id": "automatic-creation-and-removal-of-keys-ex26",
      "language": "rust",
      "code": "if let Ok(res) = r.del(\"new_bikes\").await {\n            let res: usize = res;\n            println!(\"{res}\"); // >>> 1\n        }\n\n        if let Ok(res) = r.set(\"new_bikes\", \"bike:1\").await {\n            let res: String = res;\n            println!(\"{res}\"); // >>> OK\n        }\n\n        if let Ok(res) = r.key_type(\"new_bikes\").await {\n            let res: ValueType = res;\n            let res: String = res.into();\n            println!(\"{res}\"); // >>> string\n        }\n\n        let res: redis::RedisResult<usize> = r.lpush(\"new_bikes\", &[\"bike:2\", \"bike:3\"]).await;\n        match res {\n            Ok(_) => {}\n            Err(e) => {\n                let msg = e.to_string();\n                if let Some((_, tail)) = msg.split_once(\"WRONGTYPE \") {\n                    println!(\"WRONGTYPE {tail}\");\n                } else {\n                    println!(\"{msg}\");\n                }\n            }\n        }",
      "section_id": "automatic-creation-and-removal-of-keys"
    },
    {
      "id": "automatic-creation-and-removal-of-keys-ex27",
      "language": "rust",
      "code": "if let Ok(res) = r.del(\"new_bikes\") {\n            let res: usize = res;\n            println!(\"{res}\"); // >>> 1\n        }\n\n        if let Ok(res) = r.set(\"new_bikes\", \"bike:1\") {\n            let res: String = res;\n            println!(\"{res}\"); // >>> OK\n        }\n\n        if let Ok(res) = r.key_type(\"new_bikes\") {\n            let res: ValueType = res;\n            let res: String = res.into();\n            println!(\"{res}\"); // >>> string\n        }\n\n        let res: redis::RedisResult<usize> = r.lpush(\"new_bikes\", &[\"bike:2\", \"bike:3\"]);\n        match res {\n            Ok(_) => {}\n            Err(e) => {\n                let msg = e.to_string();\n                if let Some((_, tail)) = msg.split_once(\"WRONGTYPE \") {\n                    println!(\"WRONGTYPE {tail}\");\n                } else {\n                    println!(\"{msg}\");\n                }\n            }\n        }",
      "section_id": "automatic-creation-and-removal-of-keys"
    },
    {
      "id": "automatic-creation-and-removal-of-keys-ex28",
      "language": "plaintext",
      "code": "> DEL bikes:repairs\n(integer) 1\n> LPUSH bikes:repairs bike:1 bike:2 bike:3\n(integer) 3\n> EXISTS bikes:repairs\n(integer) 1\n> LPOP bikes:repairs\n\"bike:3\"\n> LPOP bikes:repairs\n\"bike:2\"\n> LPOP bikes:repairs\n\"bike:1\"\n> EXISTS bikes:repairs\n(integer) 0",
      "section_id": "automatic-creation-and-removal-of-keys"
    },
    {
      "id": "automatic-creation-and-removal-of-keys-ex29",
      "language": "csharp",
      "code": "long res40 = db.ListLeftPush(\"bikes:repairs\", [\"bike:1\", \"bike:2\", \"bike:3\"]);\n        Console.WriteLine(res40);   // >>> 3\n\n        bool res41 = db.KeyExists(\"bikes:repairs\");\n        Console.WriteLine(res41);   // >>> True\n\n        RedisValue res42 = db.ListLeftPop(\"bikes:repairs\");\n        Console.WriteLine(res42);   // >>> \"bike:3\"\n\n        RedisValue res43 = db.ListLeftPop(\"bikes:repairs\");\n        Console.WriteLine(res43);   // >>> \"bike:2\"\n\n        RedisValue res44 = db.ListLeftPop(\"bikes:repairs\");\n        Console.WriteLine(res44);   //  >>> \"bike:1\"\n\n        bool res45 = db.KeyExists(\"bikes:repairs\");\n        Console.WriteLine(res45);   // >>> False",
      "section_id": "automatic-creation-and-removal-of-keys"
    },
    {
      "id": "automatic-creation-and-removal-of-keys-ex30",
      "language": "csharp",
      "code": "db.KeyDelete(\"bikes:repairs\");\n\n        long res40 = db.ListLeftPush(\"bikes:repairs\", [\"bike:1\", \"bike:2\", \"bike:3\"]);\n        Console.WriteLine(res40);   // >>> 3\n\n        bool res41 = db.KeyExists(\"bikes:repairs\");\n        Console.WriteLine(res41);   // >>> True\n\n        RedisValue res42 = db.ListLeftPop(\"bikes:repairs\");\n        Console.WriteLine(res42);   // >>> \"bike:3\"\n\n        RedisValue res43 = db.ListLeftPop(\"bikes:repairs\");\n        Console.WriteLine(res43);   // >>> \"bike:2\"\n\n        RedisValue res44 = db.ListLeftPop(\"bikes:repairs\");\n        Console.WriteLine(res44);   //  >>> \"bike:1\"\n\n        bool res45 = db.KeyExists(\"bikes:repairs\");\n        Console.WriteLine(res45);   // >>> False",
      "section_id": "automatic-creation-and-removal-of-keys"
    },
    {
      "id": "automatic-creation-and-removal-of-keys-ex31",
      "language": "csharp",
      "code": "long res40 = db.ListLeftPush(\"bikes:repairs\", [\"bike:1\", \"bike:2\", \"bike:3\"]);\n        Console.WriteLine(res40);   // >>> 3\n\n        bool res41 = db.KeyExists(\"bikes:repairs\");\n        Console.WriteLine(res41);   // >>> True\n\n        RedisValue res42 = db.ListLeftPop(\"bikes:repairs\");\n        Console.WriteLine(res42);   // >>> \"bike:3\"\n\n        RedisValue res43 = db.ListLeftPop(\"bikes:repairs\");\n        Console.WriteLine(res43);   // >>> \"bike:2\"\n\n        RedisValue res44 = db.ListLeftPop(\"bikes:repairs\");\n        Console.WriteLine(res44);   //  >>> \"bike:1\"\n\n        bool res45 = db.KeyExists(\"bikes:repairs\");\n        Console.WriteLine(res45);   // >>> False",
      "section_id": "automatic-creation-and-removal-of-keys"
    },
    {
      "id": "automatic-creation-and-removal-of-keys-ex32",
      "language": "csharp",
      "code": "db.KeyDelete(\"bikes:repairs\");\n\n        long res40 = db.ListLeftPush(\"bikes:repairs\", [\"bike:1\", \"bike:2\", \"bike:3\"]);\n        Console.WriteLine(res40);   // >>> 3\n\n        bool res41 = db.KeyExists(\"bikes:repairs\");\n        Console.WriteLine(res41);   // >>> True\n\n        RedisValue res42 = db.ListLeftPop(\"bikes:repairs\");\n        Console.WriteLine(res42);   // >>> \"bike:3\"\n\n        RedisValue res43 = db.ListLeftPop(\"bikes:repairs\");\n        Console.WriteLine(res43);   // >>> \"bike:2\"\n\n        RedisValue res44 = db.ListLeftPop(\"bikes:repairs\");\n        Console.WriteLine(res44);   //  >>> \"bike:1\"\n\n        bool res45 = db.KeyExists(\"bikes:repairs\");\n        Console.WriteLine(res45);   // >>> False",
      "section_id": "automatic-creation-and-removal-of-keys"
    },
    {
      "id": "automatic-creation-and-removal-of-keys-ex33",
      "language": "go",
      "code": "rdb.Del(ctx, \"bikes:repairs\")\n\tres42, err := rdb.LPush(ctx, \"bikes:repairs\", \"bike:1\", \"bike:2\", \"bike:3\").Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(res42) // >>> 3\n\n\tres43, err := rdb.Exists(ctx, \"bikes:repairs\").Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(res43) // >>> 1\n\n\tres44, err := rdb.LPop(ctx, \"bikes:repairs\").Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(res44) // >>> bike:3\n\n\tres45, err := rdb.LPop(ctx, \"bikes:repairs\").Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(res45) // >>> bike:2\n\n\tres46, err := rdb.LPop(ctx, \"bikes:repairs\").Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(res46) // >>> bike:1\n\n\tres47, err := rdb.Exists(ctx, \"bikes:repairs\").Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(res47) // >>> 0",
      "section_id": "automatic-creation-and-removal-of-keys"
    },
    {
      "id": "automatic-creation-and-removal-of-keys-ex34",
      "language": "java",
      "code": "CompletableFuture<Void> rule2 = asyncCommands.lpush(\"bikes:repairs\", \"bike:1\", \"bike:2\", \"bike:3\")\n                    .thenCompose(res30 -> {\n                        System.out.println(res30); // >>> 3\n\n                        return asyncCommands.exists(\"bikes:repairs\");\n                    }).thenCompose(res31 -> {\n                        System.out.println(res31); // >>> 1\n\n                        return asyncCommands.lpop(\"bikes:repairs\");\n                    }).thenCompose(res32 -> {\n                        System.out.println(res32); // >>> bike:3\n\n                        return asyncCommands.lpop(\"bikes:repairs\");\n                    }).thenCompose(res33 -> {\n                        System.out.println(res33); // >>> bike:2\n\n                        return asyncCommands.lpop(\"bikes:repairs\");\n                    }).thenCompose(res34 -> {\n                        System.out.println(res34); // >>> bike:1\n\n                        return asyncCommands.exists(\"bikes:repairs\");\n                    })\n                    .thenAccept(System.out::println) // >>> 0\n                    .toCompletableFuture();",
      "section_id": "automatic-creation-and-removal-of-keys"
    },
    {
      "id": "automatic-creation-and-removal-of-keys-ex35",
      "language": "java",
      "code": "jedis.del(\"bikes:repairs\");\n\n        jedis.lpush(\"bikes:repairs\", \"bike:1\", \"bike:2\", \"bike:3\");\n        System.out.println(res36);  // >>> 3\n\n        boolean res40 = jedis.exists(\"bikes:repairs\");\n        System.out.println(res40);  // >>> true\n\n        String res41 = jedis.lpop(\"bikes:repairs\");\n        System.out.println(res41);  // >>> bike:3\n\n        String res42 = jedis.lpop(\"bikes:repairs\");\n        System.out.println(res42);  // >>> bike:2\n\n        String res43 = jedis.lpop(\"bikes:repairs\");\n        System.out.println(res43);  // >>> bike:1\n\n        boolean res44 = jedis.exists(\"bikes:repairs\");\n        System.out.println(res44);  // >>> false",
      "section_id": "automatic-creation-and-removal-of-keys"
    },
    {
      "id": "automatic-creation-and-removal-of-keys-ex36",
      "language": "javascript",
      "code": "await client.del('bikes:repairs');\n\nawait client.lPush('bikes:repairs', ['bike:1', 'bike:2', 'bike:3']);\nconsole.log(res36);  // 3\n\nconst res40 = await client.exists('bikes:repairs')\nconsole.log(res40);  // 1\n\nconst res41 = await client.lPop('bikes:repairs');\nconsole.log(res41);  // 'bike:3'\n\nconst res42 = await client.lPop('bikes:repairs');\nconsole.log(res42);  // 'bike:2'\n\nconst res43 = await client.lPop('bikes:repairs');\nconsole.log(res43);  // 'bike:1'\n\nconst res44 = await client.exists('bikes:repairs');\nconsole.log(res44);  // 0",
      "section_id": "automatic-creation-and-removal-of-keys"
    },
    {
      "id": "automatic-creation-and-removal-of-keys-ex37",
      "language": "php",
      "code": "$r->del('bikes:repairs');\n        $res36 = $r->lpush('bikes:repairs', 'bike:1', 'bike:2', 'bike:3');\n        echo $res36 . PHP_EOL;\n        // >>> 3\n\n        $res40 = $r->exists('bikes:repairs');\n        echo $res40 . PHP_EOL;\n        // >>> 1\n\n        $res41 = $r->lpop('bikes:repairs');\n        echo $res41 . PHP_EOL;\n        // >>> 'bike:3'\n\n        $res42 = $r->lpop('bikes:repairs');\n        echo $res42 . PHP_EOL;\n        // >>> 'bike:2'\n\n        $res43 = $r->lpop('bikes:repairs');\n        echo $res43 . PHP_EOL;\n        // >>> 'bike:1'\n\n        $res44 = $r->exists('bikes:repairs');\n        echo $res44 . PHP_EOL;\n        // >>> False",
      "section_id": "automatic-creation-and-removal-of-keys"
    },
    {
      "id": "automatic-creation-and-removal-of-keys-ex38",
      "language": "python",
      "code": "r.delete(\"bikes:repairs\")\n\nr.lpush(\"bikes:repairs\", \"bike:1\", \"bike:2\", \"bike:3\")\nprint(res36)  # >>> 3\n\nres40 = r.exists(\"bikes:repairs\")\nprint(res40)  # >>> 1\n\nres41 = r.lpop(\"bikes:repairs\")\nprint(res41)  # >>> 'bike:3'\n\nres42 = r.lpop(\"bikes:repairs\")\nprint(res42)  # >>> 'bike:2'\n\nres43 = r.lpop(\"bikes:repairs\")\nprint(res43)  # >>> 'bike:1'\n\nres44 = r.exists(\"bikes:repairs\")\nprint(res44)  # >>> False",
      "section_id": "automatic-creation-and-removal-of-keys"
    },
    {
      "id": "automatic-creation-and-removal-of-keys-ex39",
      "language": "ruby",
      "code": "r.del('bikes:repairs')\n\nres44 = r.lpush('bikes:repairs', ['bike:1', 'bike:2', 'bike:3'])\nputs res44 # >>> 3\n\nres45 = r.exists('bikes:repairs')\nputs res45 # >>> 1\n\nres46 = r.lpop('bikes:repairs')\nputs res46 # >>> bike:3\n\nres47 = r.lpop('bikes:repairs')\nputs res47 # >>> bike:2\n\nres48 = r.lpop('bikes:repairs')\nputs res48 # >>> bike:1\n\nres49 = r.exists('bikes:repairs')\nputs res49 # >>> 0",
      "section_id": "automatic-creation-and-removal-of-keys"
    },
    {
      "id": "automatic-creation-and-removal-of-keys-ex40",
      "language": "rust",
      "code": "let _: usize = r.rpush(\"bikes:repairs\", \"bike:placeholder\").await.unwrap_or(0);\n        if let Ok(res) = r.del(\"bikes:repairs\").await {\n            let res: usize = res;\n            println!(\"{res}\"); // >>> 1\n        }\n\n        if let Ok(res) = r.lpush(\"bikes:repairs\", &[\"bike:1\", \"bike:2\", \"bike:3\"]).await {\n            let res: usize = res;\n            println!(\"{res}\"); // >>> 3\n        }\n\n        if let Ok(res) = r.exists(\"bikes:repairs\").await {\n            let res: bool = res;\n            println!(\"{}\", i32::from(res)); // >>> 1\n        }\n\n        if let Ok(res) = r.lpop(\"bikes:repairs\", None).await {\n            let res: Option<String> = res;\n            print_optional_string(res.clone()); // >>> bike:3\n        }\n\n        if let Ok(res) = r.lpop(\"bikes:repairs\", None).await {\n            let res: Option<String> = res;\n            print_optional_string(res.clone()); // >>> bike:2\n        }\n\n        if let Ok(res) = r.lpop(\"bikes:repairs\", None).await {\n            let res: Option<String> = res;\n            print_optional_string(res.clone()); // >>> bike:1\n        }\n\n        if let Ok(res) = r.exists(\"bikes:repairs\").await {\n            let res: bool = res;\n            println!(\"{}\", i32::from(res)); // >>> 0\n        }",
      "section_id": "automatic-creation-and-removal-of-keys"
    },
    {
      "id": "automatic-creation-and-removal-of-keys-ex41",
      "language": "rust",
      "code": "let _: usize = r.rpush(\"bikes:repairs\", \"bike:placeholder\").unwrap_or(0);\n        if let Ok(res) = r.del(\"bikes:repairs\") {\n            let res: usize = res;\n            println!(\"{res}\"); // >>> 1\n        }\n\n        if let Ok(res) = r.lpush(\"bikes:repairs\", &[\"bike:1\", \"bike:2\", \"bike:3\"]) {\n            let res: usize = res;\n            println!(\"{res}\"); // >>> 3\n        }\n\n        if let Ok(res) = r.exists(\"bikes:repairs\") {\n            let res: bool = res;\n            println!(\"{}\", i32::from(res)); // >>> 1\n        }\n\n        if let Ok(res) = r.lpop(\"bikes:repairs\", None) {\n            let res: Option<String> = res;\n            print_optional_string(res.clone()); // >>> bike:3\n        }\n\n        if let Ok(res) = r.lpop(\"bikes:repairs\", None) {\n            let res: Option<String> = res;\n            print_optional_string(res.clone()); // >>> bike:2\n        }\n\n        if let Ok(res) = r.lpop(\"bikes:repairs\", None) {\n            let res: Option<String> = res;\n            print_optional_string(res.clone()); // >>> bike:1\n        }\n\n        if let Ok(res) = r.exists(\"bikes:repairs\") {\n            let res: bool = res;\n            println!(\"{}\", i32::from(res)); // >>> 0\n        }",
      "section_id": "automatic-creation-and-removal-of-keys"
    },
    {
      "id": "automatic-creation-and-removal-of-keys-ex42",
      "language": "plaintext",
      "code": "> DEL bikes:repairs\n(integer) 1\n> LLEN bikes:repairs\n(integer) 0\n> LPOP bikes:repairs\n(nil)",
      "section_id": "automatic-creation-and-removal-of-keys"
    },
    {
      "id": "automatic-creation-and-removal-of-keys-ex43",
      "language": "csharp",
      "code": "bool res46 = db.KeyDelete(\"bikes:repairs\");\n        Console.WriteLine(res46);   // >>> False\n\n        long res47 = db.ListLength(\"bikes:repairs\");\n        Console.WriteLine(res47);   // >>> 0\n\n        RedisValue res48 = db.ListLeftPop(\"bikes:repairs\");\n        Console.WriteLine(res48);   // >>> Null",
      "section_id": "automatic-creation-and-removal-of-keys"
    },
    {
      "id": "automatic-creation-and-removal-of-keys-ex44",
      "language": "csharp",
      "code": "db.KeyDelete(\"bikes:repairs\");\n\n        long res47 = db.ListLength(\"bikes:repairs\");\n        Console.WriteLine(res47);   // >>> 0\n\n        RedisValue res48 = db.ListLeftPop(\"bikes:repairs\");\n        Console.WriteLine(res48);   // >>> Null",
      "section_id": "automatic-creation-and-removal-of-keys"
    },
    {
      "id": "automatic-creation-and-removal-of-keys-ex45",
      "language": "csharp",
      "code": "bool res46 = db.KeyDelete(\"bikes:repairs\");\n        Console.WriteLine(res46);   // >>> False\n\n        long res47 = db.ListLength(\"bikes:repairs\");\n        Console.WriteLine(res47);   // >>> 0\n\n        RedisValue res48 = db.ListLeftPop(\"bikes:repairs\");\n        Console.WriteLine(res48);   // >>> Null",
      "section_id": "automatic-creation-and-removal-of-keys"
    },
    {
      "id": "automatic-creation-and-removal-of-keys-ex46",
      "language": "csharp",
      "code": "db.KeyDelete(\"bikes:repairs\");\n\n        long res47 = db.ListLength(\"bikes:repairs\");\n        Console.WriteLine(res47);   // >>> 0\n\n        RedisValue res48 = db.ListLeftPop(\"bikes:repairs\");\n        Console.WriteLine(res48);   // >>> Null",
      "section_id": "automatic-creation-and-removal-of-keys"
    },
    {
      "id": "automatic-creation-and-removal-of-keys-ex47",
      "language": "go",
      "code": "rdb.Del(ctx, \"bikes:repairs\")\n\n\tres48, err := rdb.Del(ctx, \"bikes:repairs\").Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(res48) // >>> 0\n\n\tres49, err := rdb.LLen(ctx, \"bikes:repairs\").Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(res49) // >>> 0\n\n\tres50, err := rdb.LPop(ctx, \"bikes:repairs\").Result()\n\n\tif err != nil {\n\t\tfmt.Println(err) // >>> redis: nil\n\t}\n\n\tfmt.Println(res50) // >>> <empty string>",
      "section_id": "automatic-creation-and-removal-of-keys"
    },
    {
      "id": "automatic-creation-and-removal-of-keys-ex48",
      "language": "java",
      "code": "CompletableFuture<Void> rule3 = asyncCommands.del(\"bikes:repairs\").thenCompose(res35 -> {\n                System.out.println(res35); // >>> 0\n\n                return asyncCommands.llen(\"bikes:repairs\");\n            }).thenCompose(res36 -> {\n                System.out.println(res36); // >>> 0\n\n                return asyncCommands.lpop(\"bikes:repairs\");\n            })\n                    .thenAccept(System.out::println) // >>> null\n                    .toCompletableFuture();",
      "section_id": "automatic-creation-and-removal-of-keys"
    },
    {
      "id": "automatic-creation-and-removal-of-keys-ex49",
      "language": "java",
      "code": "jedis.del(\"bikes:repairs\");\n\n        long res46 = jedis.llen(\"bikes:repairs\");\n        System.out.println(res46);  // >>> 0\n\n        String res47 = jedis.lpop(\"bikes:repairs\");\n        System.out.println(res47);  // >>> null",
      "section_id": "automatic-creation-and-removal-of-keys"
    },
    {
      "id": "automatic-creation-and-removal-of-keys-ex50",
      "language": "javascript",
      "code": "await client.del('bikes:repairs');\n\nconst res45 = await client.del('bikes:repairs');\nconsole.log(res45);  // 0\n\nconst res46 = await client.lLen('bikes:repairs');\nconsole.log(res46);  // 0\n\nconst res47 = await client.lPop('bikes:repairs');\nconsole.log(res47);  // null",
      "section_id": "automatic-creation-and-removal-of-keys"
    },
    {
      "id": "automatic-creation-and-removal-of-keys-ex51",
      "language": "php",
      "code": "$res45 = $r->del('bikes:repairs');\n        echo $res45 . PHP_EOL;\n        // >>> 0\n\n        $res46 = $r->llen('bikes:repairs');\n        echo $res46 . PHP_EOL;\n        // >>> 0\n\n        $res47 = $r->lpop('bikes:repairs');\n        echo $res47 . PHP_EOL;\n        // >>> None",
      "section_id": "automatic-creation-and-removal-of-keys"
    },
    {
      "id": "automatic-creation-and-removal-of-keys-ex52",
      "language": "python",
      "code": "r.delete(\"bikes:repairs\")\n\nres45 = r.delete(\"bikes:repairs\")\nprint(res45)  # >>> 0\n\nres46 = r.llen(\"bikes:repairs\")\nprint(res46)  # >>> 0\n\nres47 = r.lpop(\"bikes:repairs\")\nprint(res47)  # >>> None",
      "section_id": "automatic-creation-and-removal-of-keys"
    },
    {
      "id": "automatic-creation-and-removal-of-keys-ex53",
      "language": "ruby",
      "code": "r.del('bikes:repairs')\n\nres50 = r.del('bikes:repairs')\nputs res50 # >>> 0\n\nres51 = r.llen('bikes:repairs')\nputs res51 # >>> 0\n\nres52 = r.lpop('bikes:repairs')\nputs res52.inspect # >>> nil",
      "section_id": "automatic-creation-and-removal-of-keys"
    },
    {
      "id": "automatic-creation-and-removal-of-keys-ex54",
      "language": "rust",
      "code": "if let Ok(res) = r.del(\"bikes:repairs\").await {\n            let res: usize = res;\n            println!(\"{res}\"); // >>> 0\n        }\n\n        if let Ok(res) = r.llen(\"bikes:repairs\").await {\n            let res: usize = res;\n            println!(\"{res}\"); // >>> 0\n        }\n\n        if let Ok(res) = r.lpop(\"bikes:repairs\", None).await {\n            let res: Option<String> = res;\n            print_optional_string(res.clone()); // >>> (nil)\n        }",
      "section_id": "automatic-creation-and-removal-of-keys"
    },
    {
      "id": "automatic-creation-and-removal-of-keys-ex55",
      "language": "rust",
      "code": "if let Ok(res) = r.del(\"bikes:repairs\") {\n            let res: usize = res;\n            println!(\"{res}\"); // >>> 0\n        }\n\n        if let Ok(res) = r.llen(\"bikes:repairs\") {\n            let res: usize = res;\n            println!(\"{res}\"); // >>> 0\n        }\n\n        if let Ok(res) = r.lpop(\"bikes:repairs\", None) {\n            let res: Option<String> = res;\n            print_optional_string(res.clone()); // >>> (nil)\n        }",
      "section_id": "automatic-creation-and-removal-of-keys"
    }
  ]
}
