GETSET
Since 1.1.0Strings
Syntax
GETSET key valueSets key to value and returns the value it held before, in one step. The key's expiry is removed. SET key value GET does the same.
Reply
- The old value, or
nilif the key did not exist. - A
WRONGTYPEerror if the key holds another type; the key is left as it was.
Examples
> SET a 1
OK
> GETSET a new
"1"
> GET a
"new"
Before 1.2, GETSET of a key of another type replaced it with the string and then replied WRONGTYPE.