STRLEN · Valkey

STRLEN

Returns the length of a string value.

Usage

STRLEN key

Description

Returns the length of the string value stored at key. An error is returned when key holds a non-string value.

Reply

Integer reply: the length of the string stored at key, or 0 when the key does not exist.

Complexity

O(1)

ACL Categories

@fast @read @string

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

History

See also

APPEND, DECR, DECRBY, GET, GETDEL, GETEX, GETRANGE, INCR, INCRBY, INCRBYFLOAT, LCS, MGET, MSET, MSETNX, SET, SETRANGE.