GETSET

Replaces a string value and returns its previous value.

Strings · Example verified

Syntax covered here

GETSET key value

The case begins with an existing string and confirms that the reply contains the value from before replacement.

Tested example & replies

Requests below run in order against an empty database. Each connection authenticates with the fixture password first. Quoted values are strings; null is a nil reply; arrays preserve RESP order.

# connection: default
> SET greeting hello
"OK"
# connection: default
> GETSET greeting world
"hello"