zoukankan      html  css  js  c++  java
  • Redis:WRONGTYPE Operation against a key holding the wrong kind of value

    相关连接:通过Canal保证某网站的Redis与MySql的数据自动同步


    1.错误信息

    redis.clients.jedis.exceptions.JedisDataException: WRONGTYPE Operation against a key holding the wrong kind of value
    

    2.分析

    当前程序中key的操作类型,并不与redis库中存在的key的类型相匹配。举例
    第一次保存key,将其设置为key-value形式

    [root@server3 src]# ./redis-cli -h 192.168.6.123 -p 6379 -a "{password}"
    192.168.6.123:6379> set my_test_userid_001 "0001"
    OK
    192.168.6.123:6379> get my_test_userid_001
    "0001"

    第二次保存key,将其以key-map形式进行保存,则会报错

    192.168.6.123:6379> hmset my_test_userid_001 user001 "0001" user002 "0002"
    (error) WRONGTYPE Operation against a key holding the wrong kind of value

    如果删除之前的key,则当前的操作可以进行:

    192.168.6.123:6379> del my_test_userid_001
    (integer) 1
    192.168.6.123:6379> hmset my_test_userid_001 user001 "0001" user002 "0002"
    OK
    192.168.6.123:6379> hgetall my_test_userid_001
    1) "user001"
    2) "0001"
    3) "user002"
    4) "0002"
    192.168.6.123:6379> hmget my_test_userid_001 user001
    1) "0001"
    192.168.6.123:6379> del my_test_userid_001
    (integer) 1

    3.问题解决

    3.1.临时解决

    删除冲突key,类似于:

    192.168.6.123:6379> del my_test_userid_001

    3.2.根本解决

    造成这个问题,肯定是程序在多处使用了同一个key,并且是以不同的类型,有的以key-value类型,有的以key-map,有的以key-object。
    查看程序,找到这个冲突,并修改。

    原文地址:https://blog.csdn.net/hanchao5272/article/details/79051364
  • 相关阅读:
    一种循环方式
    SqlServer循环读取配置
    app抓包
    c# 前端写代码的情况
    第36月第27日 codesign重签名
    第36月第26天 吴恩达 目标检测
    第36月第25天 TensorFlow Object_detection
    第36月第19天 多个tomcat查端口
    第36月第8天 flask_bootstrap
    第36月第5天 升级到 XCode10.3 项目中的xib报错
  • 原文地址:https://www.cnblogs.com/jpfss/p/11015139.html
Copyright © 2011-2022 走看看