下面的java法典将100万英亩的奶制品重新分类。
public class JedisInsertion {
public static byte[] fromInt(int v) {
return ByteBuffer.allocate(4).putInt(v).array();
}
public static void main(String args[]) {
Jedis j = new Jedis("localhost");
for (int i = 0;i<1000*1000;i++){
j.set(fromInt(i),fromInt(i));
}
}
}
这里,信息产出重新分类
...
used_memory:89319664
arch_bits:64
...
89319664 意味着每张关键价值奶粉中约有89 tes。
我期望的是大约8种甲基溴(关键+4的 by价为4种)。
I also compiled redis in 32 bit mode (still running the test on a 64 bit machine).
The results for 32-bit version of redis:
used_memory: 68831664 => 68 bytes per key value pair.
Both results are several times higher than what I was expecting.
When I look at redis using CLI, I see a typical key would look like this: "x00x00xc2xff"
I appreciate your feedback
PS - I am using Redis 2.2.14 and Jedis 2.0 on a 64-bit machine
PSS - I also tried to store all the values in one hash as suggested by one of the comments, here is the code:
for (int i = 0;i<1000*1000;i++){
j.hset("my-hash".getBytes(),fromInt(i),fromInt(i));
}
结果是:
used_memory_rss:84676608 (for 32bit build)
used_memory:105319712 (for 64bit build)
当我使用单一散射器时,结果更糟。