Redis - String Getset 命令



Redis GETSET 命令在 Redis 鍵中設定指定的字串值,並返回其舊值。

返回值

簡單字串回覆,該鍵的舊值。如果鍵不存在,則返回 nil。

語法

以下是 Redis GETSET 命令的基本語法。

redis 127.0.0.1:6379> GETSET KEY_NAME VALUE

示例

redis 127.0.0.1:6379> GETSET mynewkey "This is my test key" 
(nil) 
redis 127.0.0.1:6379> GETSET mynewkey "This is my new value to test getset" 
"This is my test key"
redis_strings.htm
廣告