无涯教程-Redis - GETSET 命令函数

61 阅读1分钟

Redis GETSET 命令在Redis键中设置指定的字符串值并返回其旧值。

GETSET - 返回值

简单的字符串回复,键的旧值,如果键不存在,则返回nil。

GETSET - 语法

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

redis 127.0.0.1:6379> GETSET KEY_NAME VALUE

GETSET - 示例

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"

参考链接

www.learnfk.com/redis/strin…