您当前的位置: 首页 > 慢生活 > 程序人生 网站首页程序人生
redis的dump命令(序列化key)
发布时间:2021-10-24 19:05:19编辑:雪饮阅读()
Redis DUMP 命令用于序列化给定 key ,并返回被序列化的值。
可用版本
>= 2.6.0
返回值
如果 key 不存在,那么返回 nil(前提是非row的连接)。否则,返回序列化之后的值。
那么以下实例符合上面的知识点:
[root@localhost ~]# /usr/local/redis-6.2.5/src/redis-cli -h 127.0.0.1 -p 6379 -a "foobared" --raw
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
127.0.0.1:6379> get test1
你好
127.0.0.1:6379> dump test1
你好 ▒▒d!q▒W
127.0.0.1:6379> dump test2
127.0.0.1:6379> dump test333
这里test2和test333都是不存在的key。
这里没有出现nil。是因为连接是row的。
用一个非row的再次对不存在的test333进行序列化就可以看到nil了:
[root@localhost ~]# /usr/local/redis-6.2.5/src/redis-cli -h 127.0.0.1 -p 6379 -a "foobared"
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
127.0.0.1:6379> dump test333
(nil)
关键字词:redis,dump,key,序列化
下一篇:redis命令exists