strlen.3valkey - Man Page

Returns the length of a string value.

Synopsis

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: the length of the string stored at key, or 0 when the key does not exist.

Complexity

O(1)

Acl Categories

@fast @read @string

History

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

See Also

append(3valkey), decr(3valkey), decrby(3valkey), delex(3valkey), delifeq(3valkey), get(3valkey), getdel(3valkey), getex(3valkey), getrange(3valkey), getset(3valkey), incr(3valkey), incrby(3valkey), incrbyfloat(3valkey), increx(3valkey), lcs(3valkey), mget(3valkey), mset(3valkey), msetex(3valkey), msetnx(3valkey), psetex(3valkey), set(3valkey), setex(3valkey), setnx(3valkey), setrange(3valkey), substr(3valkey)

Info

2026-11-19 9.2.0 Valkey Command Manual