SETRANGE
AttentionThis page documents an earlier version. Go to the latest (v2.1)version.
Synopsis
SETRANGE key offset valueThis command overwrites the string that is associated with the given key with the given value, starting from the given offset.
- The
offsetcannot exceed 536870911. - If the
offsetis larger than the length of the specified string, the string will be padded with zeros up to theoffset. - If the
keydoes not exist, its associated string is an empty string. The resulted new string is constructed with zeros up to the givenoffsetand then appended with the givenvalue. - If the
keyis associated with a non-string value, an error is raised.
Return Value
Returns the length of the resulted string after overwriting.
Examples
You can do this as shown below.
1. $ SET yugakey "YugaKey"
1. "OK"
1. $ SETRANGE yugakey 4 "Byte"
1. 8
1. $ GET yugakey
1. "Yugabyte"
