Redis Strlen Command
The Redis Strlen command is used to get the length of the string value stored at the specified key. An error is returned when the key stores a value that is not a string.
Syntax
The basic syntax of 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. Returns 0 when the key does not exist.
Example
# 获取字符串的长度 redis> SET mykey "Hello world" OK redis> STRLEN mykey (integer) 11 # 不存在的 key 长度为 0 redis> STRLEN nonexisting (integer) 0Other Extensions
Redis String