Related connections: Through the canal to ensure the redis of a website and MySQL data automatically synchronized 1. Error message
Redis.clients.jedis.exceptions.JedisDataException:WRONGTYPE Operation against a key holding the wrong kind of value
2. Analysis
The operation type of key in the current program does not match the type of key that exists in the Redis library. Example
Save key for the first time, set it to Key-value form
[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"
Save the key for the second time, save it as Key-map, and you will get an error
192.168.6.123:6379> hmset my_test_userid_001 user001 "0001" user002 "0002"
(Error) Wrongtype Operation a K EY holding the wrong kind of value
If you delete the previous key, the current operation can take place:
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. Problem solving 3.1. Temporary solution
Delete conflict key, similar to:
192.168.6.123:6379> del my_test_userid_001
3.2. A fundamental solution
Cause this problem, must be the program in many places use the same key, and is different type, some to Key-value type, some to Key-map, some to Key-object.
View the program, find the conflict, and modify it.