Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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#?

like image 897
Praveen Mohan Avatar asked Sep 22 '15 05:09

Praveen Mohan


1 Answers

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") });
like image 165
thepirat000 Avatar answered Oct 21 '22 22:10

thepirat000