content/commands/linsert.md
Inserts element in the list stored at key either before or after the reference
value pivot.
When key does not exist, it is considered an empty list and no operation is
performed.
An error is returned when key exists but does not hold a list value.
{{% redis-cli %}} RPUSH mylist "Hello" RPUSH mylist "World" LINSERT mylist BEFORE "World" "There" LRANGE mylist 0 -1 {{% /redis-cli %}}
| Redis Software | Redis Cloud | <span style="min-width: 9em; display: table-cell">Notes</span> | |:----------------------|:-----------------|:------| | <span title="Supported">✅ Standard</span> <span title="Supported"><nobr>✅ Active-Active</nobr></span> | <span title="Supported">✅ Standard</span> <span title="Supported"><nobr>✅ Active-Active</nobr></span> | |
{{< multitabs id="linsert-return-info" tab1="RESP2" tab2="RESP3" >}}
One of the following:
0 when the key doesn't exist.-1 when the pivot wasn't found.-tab-sep-
One of the following:
0 when the key doesn't exist.-1 when the pivot wasn't found.{{< /multitabs >}}