Skip to main content
Use SETRANGE to overwrite part of the string stored at a key, starting at a byte offset. The key is created when it does not exist, and if the offset lies past the current end of the value the string is first padded with zero bytes, so writing at a large offset allocates everything up to it. The reply is the length of the string after the write. Together with GETRANGE this makes it possible to treat a string as a fixed-layout record and update one field in place, without reading and rewriting the whole value.

Syntax

Arguments

Response

The reply reports the result of the operation. Error replies have the same shape in RESP2 and RESP3 and are surfaced as exceptions by the SDKs below.
Client libraries often decode bulk strings, maps, sets, and numeric strings into language-native values. The table describes the Redis wire reply.

Examples

TCP examples use the TLS REDIS_URL from the Upstash console. REST examples use UPSTASH_REDIS_REST_URL and UPSTASH_REDIS_REST_TOKEN.

Related topics

SETRANGEOverview