Redis Strlen command
The Redis Strlen command is used to get the length of the string value stored in a specified key. When the key stores a non-string value, an error is returned.
Syntax
The basic syntax of the redis Strlen command is as follows:
redis 127.0.0.1:6379> STRLEN KEY_NAME
Available Version
= 2.2.0
Return Value
The length of the string value. Returns 0 when the key does not exist.
Example
# Get the length of the string
redis> SET mykey "Hello world"
OK
redis> STRLEN mykey
(integer) 11
# The non-existent key has a length of 0
redis> STRLEN nonexisting
(integer) 0
Redis string