String

SETRANGE

Writes the value of key at offset.

The SETRANGE command in Redis is used to modify a portion of the value of a key by replacing a substring within the key's existing value. It allows you to update part of the string value associated with a specific key at a specified offset.

Arguments

keybodystrrequired

The name of the Redis key for which you want to modify the value.

offsetbodyintrequired

The zero-based index in the value where you want to start replacing characters.

valuebodystrrequired

The new string that you want to insert at the specified offset in the existing value.

Response

intrequired

The length of the value after it was modified.

Example
redis.set("key", "Hello World")assert redis.setrange("key", 6, "Redis") == 11assert redis.get("key") == "Hello Redis"
Loading search…