Redis学习之append命令

删除回忆录丶 提交于 2019-12-15 11:30:42

append命令

Redis append,命令用于为指定的 key 追加值。

  • 如果 key 已经存在并且是一个字符串, append 命令将 value 追加到 key 原来的值的末尾。
  • 如果 key 不存在, append 就简单地将给定 key 设为 value ,就像执行 set key value 一样。

语法

append key value

返回值

追加指定值之后, key 中字符串字节长度。

例子

对不存在的 key 执行 append

127.0.0.1:6379> exists test:append
(integer) 0

127.0.0.1:6379> append test:append 'good'     
(integer) 4                        

127.0.0.1:6379> get test:append
"good"

对已存在的字符串进行 append

127.0.0.1:6379> append test:append "China"    
(integer) 9

127.0.0.1:6379> GET greeting
"goodChina"
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!