Back to Redis

STRLEN

content/commands/strlen.md

latest1.1 KB
Original Source

Returns the length of the string value stored at key. An error is returned when key holds a non-string value.

Examples

{{% redis-cli %}} SET mykey "Hello world" STRLEN mykey STRLEN nonexisting {{% /redis-cli %}}

Redis Software and Redis Cloud compatibility

| 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> | |

Return information

{{< multitabs id="strlen-return-info" tab1="RESP2" tab2="RESP3" >}}

Integer reply: the length of the string stored at key, or 0 when the key does not exist.

-tab-sep-

Integer reply: the length of the string stored at key, or 0 when the key does not exist.

{{< /multitabs >}}