> ## Documentation index
> Fetch the complete documentation index at: https://upstash.com/docs/llms.txt
> Search it with GET https://upstash.com/docs/search?q=<query>.
> Use these to discover all available pages before exploring further.

# GETSET

> Return the value of the specified key and replace it with a new value.

## Arguments 

<ParamField body="key" type="str" required>
  The key to get.
</ParamField>

<ParamField body="value" type="Any" required>
  The new value to store.
</ParamField>

## Response
<ResponseField  required>
  The response is the value stored at the key or `None` if the key doesn't exist.
</ResponseField>

<RequestExample>
```py Example
redis.set("key", "old-value")

assert redis.getset("key", "newvalue") == "old-value"
```
</RequestExample>
