Jedis HMSET 地图插入顺序
Jedis HMSET map insertion order
Jedis 有一个 hmset 方法,允许您在特定键处设置字段及其值的映射。
我是这样使用方法的:
Map<String, String> map = new LinkedHashMap<String, String>();
// General player data
map.put("name", player.getName());
map.put("ip", player.getAddress().getAddress().getHostAddress());
map.put("rank", "none");
map.put("tokens", "0");
map.put("coins", "0");
// Arsenal player statistics
map.put("ar_score", "0");
map.put("ar_gameswon", "0");
map.put("ar_gameslost", "0");
map.put("ar_kills", "0");
map.put("ar_deaths", "0");
pipeline.hmset("uuid:" + uuid, map);
pipeline.sync();
core.redis.getJedisPool().returnResourceObject(jedis);
我决定使用 LinkedHashMap 来保留插入顺序 — 然而,在查看数据库时,它仍然弄乱了顺序。
有谁知道如何插入数据库而不打乱顺序吗?
谢谢。
基于字符串的 Jedis 客户端 transcodes the strings using a temporary HashMap, so it kills your order. The BinaryClient iterates over the Map 直接保留顺序。
lettuce 客户端在任何情况下都会保持地图的顺序。
或者,使用 HSET hash key value
一个一个地设置值
HTH,马克
尝试使用基于 Redis 的框架 Java - Redisson。它使用任何编解码器(Jackson JSON
、Avro
、Smile
、CBOR
、MsgPack
、Kryo
、FST
、LZ4
、Snappy
和 JDK Serialization
).
Jedis 有一个 hmset 方法,允许您在特定键处设置字段及其值的映射。
我是这样使用方法的:
Map<String, String> map = new LinkedHashMap<String, String>();
// General player data
map.put("name", player.getName());
map.put("ip", player.getAddress().getAddress().getHostAddress());
map.put("rank", "none");
map.put("tokens", "0");
map.put("coins", "0");
// Arsenal player statistics
map.put("ar_score", "0");
map.put("ar_gameswon", "0");
map.put("ar_gameslost", "0");
map.put("ar_kills", "0");
map.put("ar_deaths", "0");
pipeline.hmset("uuid:" + uuid, map);
pipeline.sync();
core.redis.getJedisPool().returnResourceObject(jedis);
我决定使用 LinkedHashMap 来保留插入顺序 — 然而,在查看数据库时,它仍然弄乱了顺序。
有谁知道如何插入数据库而不打乱顺序吗?
谢谢。
基于字符串的 Jedis 客户端 transcodes the strings using a temporary HashMap, so it kills your order. The BinaryClient iterates over the Map 直接保留顺序。
lettuce 客户端在任何情况下都会保持地图的顺序。
或者,使用 HSET hash key value
HTH,马克
尝试使用基于 Redis 的框架 Java - Redisson。它使用任何编解码器(Jackson JSON
、Avro
、Smile
、CBOR
、MsgPack
、Kryo
、FST
、LZ4
、Snappy
和 JDK Serialization
).