一叶知秋.

业精于勤,荒于嬉;行成于思,毁于随。

[Redis] (error) WRONGTYPE Operation against a key holding the wrong kind of value

环境:
centos 6.0 64位
redis 5.0.5

问题:

(error) WRONGTYPE Operation against a key holding the wrong kind of value
#(错误)对持有错误类型值的键进行错误类型操作

原因:

#使用了set的命令对zset数据类型的key进行操作导致报错
127.0.0.1:6379> smembers salary #smembers 查看指定set的值
(error) WRONGTYPE Operation against a key holding the wrong kind of value
127.0.0.1:6379> type salary
zset

正确方法:

127.0.0.1:6379> ZRANGE salary 0 -1 withscores #使用range命令获取有序集合key中指定范围的元素
1) "lisi"
2) "1000"
3) "shangzhan"
4) "2000"
5) "wangwu"
6) "5000"
posted @ 2020-09-04 08:43  ccku  阅读(3718)  评论(0编辑  收藏  举报