繁体   English   中英

尝试在地图(Jedis)中设置字符串时出现WRONGTYPE异常

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

尝试将字符串设置为值时,我收到JedisDataException异常,如果我完全无法执行操作,则似乎无法弄清楚我在哪里出错。 Jedis版本是2.9.0(我相信它是最新的)。

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的键,并且它不是哈希。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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