set
英[set] 美[sɛt]
vt. Set; place, arrange; put in a certain situation; place tableware
vi. Setting off; setting off; condensation
n.Gathering; a set; a set; a TV set
adj. Fixed; located in...; stubborn; arranged The
third person singular: sets plural: sets present participle: setting past tense: set past participle: set
range
英[reɪndʒ] Beauty [rendʒ]
n. Range; range; category; (mountains, houses, etc.) arrangement
vi. Search; change; extend; roam
vt. Arrangement ; (in a certain position or order); to classify; to wander around
adj. pasture, grazing area
Third person singular: ranges Plural: ranges Present participle: ranging Past tense: ranged past participle: ranged
redis SETRANGE command syntax
Function:Use the value parameter to overwrite the string value stored in the given key, starting from the offset offset. Keys that do not exist are treated as blank strings.
Syntax:SETRANGE key offset value
Description: TheSETRANGE command will ensure that the string is long enough to set value at the specified offset Above, if the length of the original string stored in a given key is smaller than the offset (for example, the string is only 5 characters long, but the offset you set is 10), then the space between the original characters and the offset will be filled with zeros. Bytes (zerobytes, "\x00" ) to fill. Note that the maximum offset you can use is 2^29-1(536870911) because the size of a Redis string is limited to 512 megabytes. If you need to use more space than this, you can use multiple keys.
Available versions:>= 2.2.0
Time complexity:For small (small) strings, the amortized complexity O(1). (For information about what string is "small", please refer to the APPEND command) Otherwise it is O(M), M is the length of the value parameter.
Return:The length of the string after being modified by SETRANGE.
redis SETRANGE command example
# 对非空字符串进行 SETRANGE redis> SET greeting "hello world" OK redis> SETRANGE greeting 6 "Redis" (integer) 11 redis> GET greeting "hello Redis" # 对空字符串/不存在的 key 进行 SETRANGE redis> EXISTS empty_string (integer) 0 redis> SETRANGE empty_string 5 "Redis!" # 对不存在的 key 使用 SETRANGE (integer) 11 redis> GET empty_string # 空白处被"\x00"填充 "\x00\x00\x00\x00\x00Redis!"