gpt4 book ai didi

jedis java代码中的redis异常

转载 作者:可可西里 更新时间:2023-11-01 11:00:01 27 4
gpt4 key购买 nike

我通过 jedis 在 java 上有这段代码:

int shb1 = jds.storeHypnoBeats(id1, arr1);

调用这个函数:

int storeHypnoBeats(String id,byte[] data)
{
db.lpush(id.getBytes(),data);
return 1;

}

但是当我运行 java 代码时,我得到了这个异常:

Exception in thread "main" redis.clients.jedis.exceptions.JedisDataException: ERR Operation against a key holding the wrong kind of value

这里是 arr1 和 id 的定义:

byte[] arr1 = new byte[]{1,2,3,4,5,6,7,8,9};
String id1 = "id1";

我检查过的每件事都是正确的,为什么我要 gwt 那个?!

提前致谢

最佳答案

id.getBytes() 返回字节数组,但 lpush 的签名是:

public Long lpush(String key,String... strings)

因此,键必须是字符串,而不是字节数组

关于jedis java代码中的redis异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29009205/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com