環境:
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"