-
Notifications
You must be signed in to change notification settings - Fork 76
SETRANGE
Overwrites part of the string stored at key, starting at the specified offset, for the entire length of value. If the offset is larger than the current length of the string at key, the string is padded with zero-bytes to make offset fit. Non-existing keys are considered as empty strings, so this command will make sure it holds a string large enough to be able to set value at offset.
Integer reply: the length of the string after it was modified by the command.
Basic usage:
> SET key1 "Hello World"
OK
> SETRANGE key1 6 "Redis"
(integer) 11
> GET key1
"Hello Redis"
Example of zero padding:
> SETRANGE key2 6 "Redis"
(integer) 11
> GET key2
"\u0000\u0000\u0000\u0000\u0000\u0000Redis"
APPEND, BITCOUNT, BITOP, BITPOS, DBSIZE, DECR, DECRBY, DEL, EXISTS, EXPIRE, EXPIREAT, FLUSHDB, GET, GETBIT, GETRANGE, GETSET, INCR, INCRBY, INCRBYFLOAT, KEYS, MGET, MSET, MSETNX, PDEL, PERSIST, PEXPIRE, PEXPIREAT, PTTL, RENAME, RENAMENX, SET, SETBIT, SETRANGE, STRLEN, TTL