我正在使用redis,並且希望將更多具有相同ID的項目插入到我的表格中。 這是我在Java代碼中插入項排序set和哈希在Redis的:在Redis中插入更多具有相同ID的項目到哈希中
Jedis jedis = new Jedis("localhost");
jedis.sadd("list"+customer,fur.getId());
jedis.hset("list"+customer+fur.getId(),"name", fur.getName());
jedis.hset("list"+customer+fur.getId(), "wood", fur.getWood());
jedis.hset("list"+customer+fur.getId(), "prize", fur.getPric());
然後我讓他們從Redis的到我的JTable:
p = jedis.smembers("tutorials"+customer);
for (String v : p) {
String pom;
pom = v;
model.addRow(new Object[]{jedis.hget("list"+customer+pom, "name"),
jedis.hget("list"+customer+pom, "wood"),
jedis.hget("list"+customer+pom, "prize")});
}
它的工作,但是當我想要多次添加相同的項目,它沒有做任何事情。