English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Redis STRLEN Command

Redis Strings (string)

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

Syntax

Basic Syntax of Redis STRLEN Command

redis 127.0.0.1:6379> STRLEN KEY_NAME

Available Versions

>= 2.2.0

Return value

Length of the string value. Returns 0 when the key does not exist.

Online Examples

# Get the length of a string
redis> SET mykey "Hello world"
OK
redis> STRLEN mykey
(integer) 11
# Length of non-existing key is 0
redis> STRLEN nonexisting
(integer) 0

Redis Strings (string)