STRLEN

Apply for Redis Developer Course Redis Regular Inspection / Technical Support Redis Enterprise Server

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
Note 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).
Related commands SET, SETRANGE, GETRANGE
Clients for Java Jedis, Lettuce, Redisson
Clients for C Hiredis

<< APPENDS STRLEN SETRANGE >>

Email 답글이 올라오면 이메일로 알려드리겠습니다.