1
votes

I have this code on java via jedis :

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

which calls this function :

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

}

but when I run the java code I get this exception :

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

here is the defintion of arr1 and id :

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

every thing is correct as I have checked, why do I gwt that?!

thanks in advance

1
Your key "id" is not a list, you can check key type by using redis "type" function, to sum it up you have already data in this key and it is not a list, so the operation fails. - zenbeni
actually it works fine!, I had to restart the redis server again. :) - flashdisk

1 Answers

0
votes

id.getBytes() returns an array of byte but signature of lpush is:

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

Therefore, key has to be string not an array of byte.