9

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

3
  • Have you seen the documentation on github.com/StackExchange/StackExchange.Redis ? Commented Sep 22, 2015 at 5:18
  • yes, but cant find an exact method suitable for my case Commented Sep 22, 2015 at 5:21
  • this is what i tried so far, HashEntry[] hashfield = new HashEntry[4] // contains hash entries, redisDB.HashSet("user",hashfield); Commented Sep 22, 2015 at 5:22

1 Answer 1

21

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") });
Sign up to request clarification or add additional context in comments.

1 Comment

I guess it makes sense that the documentation for StackExchange.Redis be on stackoverflow.com...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.