Easy Tutorial
❮ Server Client Pause Redis Backup ❯

Redis Strlen Command

Redis Strings

The Redis Strlen command is used to get the length of the string value stored at a specified key. If the key does not store a string value, an error is returned.

Syntax

The basic syntax for the redis Strlen command is as follows:

redis 127.0.0.1:6379> STRLEN KEY_NAME

Available Versions

= 2.2.0

Return Value

The length of the string value. If the key does not exist, it returns 0.

Examples

# Get the length of a string

redis> SET mykey "Hello world"
OK

redis> STRLEN mykey
(integer) 11

# Length of a non-existing key is 0

redis> STRLEN nonexisting
(integer) 0

Redis Strings

❮ Server Client Pause Redis Backup ❯