- Usage
STRLEN key - Complexity
- O(1)
- Since
- 2.2.0
- ACL Categories
- @fast, @read, @string
- Command flags
- READONLY, FAST
Returns the length of the string value stored at key.
An error is returned when key holds a non-string value.
Examples
127.0.0.1:6379> SET mykey "Hello world"
OK
127.0.0.1:6379> STRLEN mykey
(integer) 11
127.0.0.1:6379> STRLEN nonexisting
(integer) 0
Replies
RESP2
Integer reply: the length of the string stored at key, or 0 when the key does not exist.
RESP3
Integer reply: the length of the string stored at key, or 0 when the key does not exist.