[英]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保留插入順序-但是,在查看數據庫時,它仍然會弄亂順序。
有誰知道如何將其插入數據庫而不弄亂順序?
謝謝。
嘗試一下基於Redis的Java- Redisson框架。 它使用任何編解碼器( Jackson JSON
, Avro
, Smile
, CBOR
, MsgPack
, Kryo
, FST
, LZ4
, Snappy
和JDK Serialization
)在迭代過程中將地圖條目按插入順序保留。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.