【redis】WRONGTYPE Operation against a key holding the wrong kind of value

2018-04-27 15:01:50.141|ERROR|EvMessageListener|Receive MsgId:AC110006000D30F39991868BAA7BBF6B tag:1 status:ReconsumeLater
redis.clients.jedis.exceptions.JedisDataException: WRONGTYPE Operation against a key holding the wrong kind of value
	at redis.clients.jedis.Protocol.processError(Protocol.java:117)
	at redis.clients.jedis.Protocol.process(Protocol.java:151)
	at redis.clients.jedis.Protocol.read(Protocol.java:205)
	at redis.clients.jedis.Connection.readProtocolWithCheckingBroken(Connection.java:297)
	at redis.clients.jedis.Connection.getIntegerReply(Connection.java:222)
	at redis.clients.jedis.Jedis.hset(Jedis.java:606)
	at com.extracme.evready.busi.service.ServiceMessage.updateStakeRedisInfo(ServiceMessage.java:233)
	at com.extracme.evready.busi.service.ServiceMessage.handerMessage(ServiceMessage.java:139)
	at com.extracme.evready.busi.service.ServiceMessage$$FastClassBySpringCGLIB$$63c3ab5e.invoke()
	at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
	at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:720)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
	at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99)
	at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:281)^C
	at org.springframework.transaction.interceptor.T
/**
		 * 2:控制模式 - 自动下发补偿机制 状态的有效时间
		 */
		String key_expire = RedisCarportCloumn.MODE_EXPIRE_PREFIX + result.getGridStakeSeq();
//		jedis.hset(key_expire,CommonConstant.SEND_TIMES_KEY, CommonConstant.SEND_STAKE_MSG_TIMES);//限制主动下发次数
		jedis.hset(key_expire,"SEND_TIMES","3");//限制主动下发次数
//		jedisCluster.hset(key_expire,CommonConstant.SEND_TIMES_KEY, CommonConstant.SEND_STAKE_MSG_TIMES);//限制主动下发次数
		}
		jedis.close();

hset看起来没有值类型不对的样子。后来发现原来是因为redis数据库中已经存在了相同的key, 而且key对应的值类型并不是Hashkey;再调用hset时,就会抛出此错误。(ps:忽想起来,最初设置的key-val   ,后面改为hash-val)

把原来的数据清掉,重新运行就没问题了。



你可能感兴趣的:(DB)