我通过 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/