GETSET
AttentionThis page documents an earlier version. Go to the latest (v2.1)version.
Synopsis
GETSET key value
This command is an atomic read and write operation that gets the existing value that is associated with the given key
while rewriting it with the given value
.
- If the given
key
does not exist, the givenvalue
is inserted for thekey
, and null is returned. - If the given
key
is associated with non-string data, an error is raised.
Return Value
Returns the old value of the given key
.
Examples
You can do this as shown below.
$ SET yugakey 1
"OK"
$ GETSET yugakey 2
1
See Also
当前内容版权归 YugabyteDB 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 YugabyteDB .