How to write the following data to redis through jedis

CSDN Q & A 2022-02-13 08:05:04 阅读数:624

write following data redis jedis

[
{
"name": "NYZ_OptionCost",
"des": "aaa",
"value": 22.47297
},
{
"name": "SD_OptionCost",
"des": "bbb",
"value": 0
},
{
"name": "Demand_JFS",
"des": "ccc",
"value": 0
}
]

The data type is hash




Take the answer :

If help , Hope to adopt !, Look at your structure List What about the assembly , If you want to write Hash Type you need to add a key,value The value of is the set provided above , And then use HMSET The command sets one or more fields to Redis in , Such as :

Map<String, String> userProperties = new HashMap<String, String>(); userProperties.put("username", user.getUsername()); userProperties.put("firstName", user.getFirstName()); userProperties.put("lastName", user.getLastName()); userProperties.put("email", user.getEmail()); userProperties.put("password", user.getPassword()); jedis.hmset("user:" + user.getUsername(), userProperties);


Other answers 2:

jedis and redis Is there a difference


Other answers 3:

jedis api look down Very simple.

copyright:author[CSDN Q & A],Please bring the original link to reprint, thank you. https://en.javamana.com/2022/02/202202130805022810.html