简体   繁体   中英

Adding and retrieving Data sets to Redis using StackExchange.Redis

Am new to Redis. I am able to store and retrieve data to redis using this commands

hmset user:user1 12 13 14 15 

and also am to retrieve data by

hgetall user:user1

i want to do the same using stackExchange.redis on my c# program. how should i do this in c#?

To set multiple values in a hash you can call the following HashSet method overload:

ConnectionMultiplexer redis = ConnectionMultiplexer.Connect("localhost");
IDatabase db = redis.GetDatabase();
db.HashSet("user:user1", new HashEntry[] { new HashEntry("12", "13"), new HashEntry("14", "15") });

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM