w3resource

Redis String: SETRANGE

SETRANGE key offset value

Redis SETRANGE command is used to overwrite part of a string at key starting at the specified offset for the entire length of the value. If the offset is larger than the current length of the string at the key, the string is padded with zero-bytes to make offset fit. Non-existing keys are considered as empty strings.

The maximum offset that you can set is 229-1 (536870911), as Redis Strings are limited to 512 megabytes.

Syntax:

SETRANGE KEY_NAME OFFSET VALUE

Available since

2.2.0.

Return Value

Integer replies, the length of the string after it was modified by the command.

Return Value Type

Integer

Example: Redis SETRANGE

redis 127.0.0.1:6379> SET key1 "Hello World"
OK
redis 127.0.0.1:6379> SETRANGE key1 6 "Redis"
(integer) 11
redis 127.0.0.1:6379> GET key1
"Hello Redis"

Previous: SETNX
Next: STRLEN



Follow us on Facebook and Twitter for latest update.