简体   繁体   中英

WRONGTYPE exception when trying to set string in map (jedis)

I am getting a JedisDataException when trying to set a string as a value, and I can't seem to figure out where I am doing a mistake, if I am doing one at all. The Jedis version is 2.9.0 (I believe it is the latest).

redis.clients.jedis.exceptions.JedisDataException: WRONGTYPE Operation against a key holding the wrong kind of value
    at redis.clients.jedis.Protocol.processError(Protocol.java:127) ~[?:?]
    at redis.clients.jedis.Protocol.process(Protocol.java:161) ~[?:?]
    at redis.clients.jedis.Protocol.read(Protocol.java:215) ~[?:?]
    at redis.clients.jedis.Connection.readProtocolWithCheckingBroken(Connection.java:340) ~[?:?]
    at redis.clients.jedis.Connection.getIntegerReply(Connection.java:265) ~[?:?]
    at redis.clients.jedis.Jedis.hset(Jedis.java:658) ~[?:?]
    at net.ferskfisk.lobby.database.mongodb.Mongo$3.run(Mongo.java:174) ~[?:?]
    at org.bukkit.craftbukkit.v1_12_R1.scheduler.CraftTask.run(CraftTask.java:71) ~[1.12.jar:git-Spigot-3d850ec-809c399]
    at org.bukkit.craftbukkit.v1_12_R1.scheduler.CraftAsyncTask.run(CraftAsyncTask.java:52) [1.12.jar:git-Spigot-3d850ec-809c399]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [?:?]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [?:?]
    at java.lang.Thread.run(Unknown Source) [?:?]

                String name = "name";
                String string = "test";
                Jedis jedis = null;
                try {
                    jedis = Database.getInstance().getRedis().getJedisPool().getResource();
                    jedis.auth("password");
                    jedis.hset(name, "doc", string);
                } finally {
                    if(jedis != null)
                        jedis.close();
                }

在没有堆栈跟踪的情况下,最可能的解释是您已经有一个名为name的键,并且它不是哈希。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM