strlen
STRLEN
Return the byte length of the value
Returns the number of bytes in the value.
Example
| Command> | set key value
|
| Result> | OK
|
| Command> | strlen key
|
| Result> | 5
|
| Command> | append key 1234567890
|
| Result> | 15
|
| Command> | get key
|
| Result> | value1234567890
|
| Command> | strlen key
|
| Result> | 15
|
UTF-8 CJK characters
UTF-8 CJK characters use 3 bytes per character.
Example
| Command> | set key "東京"
|
| Result> | OK
|
| Command> | strlen key
|
| Result> | 6
|
| Command> | set key "東京 Seoul"
|
| Result> | OK
|
| Command> | strlen key
|
| Result> | 12
|
 |
redis-cli cannot enter CJK characters,
but the Redis Web Client on this site can. |
Syntax
STRLEN key
- Available since version 2.2.0.
- Time complexity is O(1).